Macro

Previous  Next |  Direct link to this topic

With the macro function, you are able to simulate and script events in SAP Business One. This work much like many of the preset functions in Function Buttons, but here you have much more freedom and advanced options.

image433

The configuration consists:

Macro area which of one big text-area, where you enter the macro-commands that form your user defined functionality

The Macro wizard and Macro Variables in the upper right.

The sample area (just below the text-area) that give you context specific samples.

The Macro Debugger checkbox in the lower right corner

 


The Macro-syntax is as follows:

<Command>(<arguments>);…

Each command can be on one line or on multiple lines as long as they are separated by a “;”

Arguments are entered inside the commands “()”… Some commands do not need any arguments (but still the “()”) while others need more than one argument. Multiple arguments are separated by a “|” char.

In macro's you use the B1UP Dynamic Syntax that you can learn more about here

You can use the following Macro Commands (Click link to learn more details about each command):

On top of the commands you also have Conditional Macro Commands and Macro Variables

Commands

Description

Activate

Activate Menuitems, UserTables or UDOs / Tells system it is on a new screen.

AutoPressNextPopup

Used to automate/suppress SAP Message-boxes and Prompts

B1P&D

Activate a B1 Print & Delivery Report Configuration

BackColor

Enables you to set the backcolor (background-color) of an item using a color-name

Blank

Blanks the field indicated (Blank = a text field receives an empty value).

BlankUdfSidebar

Blanks the field indicated on the UDF Sidebar (Blank = a text field receives an empty value).

Block

Blocks the SAP Event in progress (The rest of the macro will be executed)

ClearAllStoreValues

Will clear the values of all stores currently in use.

ClearValidValues

Clear custom valid values in an item that can hold valid values (Example a combo box)

Click

Click a button, item or cell

ClickGoldenArrow

Click on a golden Arrow in a Matrix or Grid

Close

Closes the current window.

CloseParent

If you during a macro open another form using the activate commands, you have the option to Close the form that opened it

CopyFrom

Automate the Copy From button on Sales and Purchase Documents

CopyTo

Automate the Copy To button on Sales and Purchase Documents

Disable

Disable an enabled field.

DoubleClick

As Click but perform a double-click instead.

DoubleClickColumnHeader

Can be used to double click a column header (Sort).

Enable

Enables a disabled field.

ExecuteBeasScript

Execute a piece of Beas-script

ExecuteSQL

[Legacy Command] Execute a Custom SQL Sentence

FirstCase

Change the casing of a string to FirstCase in an edit text or a column (“my string” >> “My String”)

Focus

Focus an Item (NB: Command Click and Focus does the same (Command is there to give better understanding and not new features))

ForeColor

Enables you to set the forecolor (text-color) of an item using a color-name

Freeze

You can use this command to block in other commands and have them run faster.

GetDate

(Conditional helper command) You can use this command to get the current data in yyyy-MM-dd format.

Hide

Hides a visible field, making it invisible to the user.

LEN

(Conditional helper command) You can use this command to get the length of a string; you can use a STORE or the dynamic syntax as input.

Lowercase

Change the casing of a string to lowercase in an edit text or a column (“MY STRING” >> “my string”)

MassDisable

Mass disabling of enabled fields (One or more)

MassEnable

Mass enabling of disabled fields (One or more)

MassHide

Mass hide visible fields, making them invisible to the user (One or more)

MassShow

Mass show previously hidden fields, making them visible again (One or more)

Messagebox

Show a message box with defined text.

MoveFocusToMainForm

Move the current Focus of the Macro-system to the main screen should you have the UDF sidebar as the current main focus (can happen in rare cases)

MultiSetFromSql

Works much like the set command, the difference being that you can set multiple values via a SQL command

OpenForm

Can open most forms with existing data given an Object type and primary key.

Panelevel

[Legacy Command] Switch Panelevel

PopFormStack

This command is quite complex but can be used if you open multiple windows in a macro but need to shift the parent/child relationship one back.

Prompt

Show a prompt with 2 or 3 buttons and depending on the user’s choice run another Universal Function.

RefreshDashboard

This command refreshes the B1 Dashboard of that user

RefreshSQLReportTabs

This command refreshes all the SQL report tabs on the active form

SendKeys

Simulate keystrokes on the keyboard  in the very rare cases other commands can't do the work

Set

Set a value in a field or cell

SetCaption

This command can be used to set the caption of an item (Button, Checkbox, Tab, Label etc.).

SetFormTitle

Set the title of the current form.

SetUdfSidebar

Works like the set command but set the value in a field on the UDF sidebar.

SetValidValues

Set a custom set of valid values in an item that accept valid values (Example a combo box)

Show

Shows a previously hidden field, making it visible again

Sleep

Will cause the system to sleep the indicated number of seconds before continuing (only make sense to use together with the SendKeys Commands)

Statusbar

Show a status message (lower left corner)

SortColumn

Sort column on a Matrix or Grid in current form.

SQL

(Conditional helper command) You can use this command together with the if/while commands to evaluate on results from the database by storing the result in a store.

SwitchToUpdateMode

Switches the current form to "update" mode.

Transfer

Transfer data between two windows after an activate (or on same window if needed)

TransferBack

Works the same as the Transfer command, but it passes data from the newly opened window back to the window that opened it.

TransferBackUdfSidebar

Works like the TransferBack command but transfer the value to the newly opened windows UDF sidebar.

TransferUdfSidebar

Works like the Transfer command but transfer the value to the newly opened windows UDF sidebar.

UF

This command allows you within a Macro to launch another universal function. Use this if you need to perform two or more universal functions on a specific event.

UnFreeze

Use this command to unfreeze a frozen form (via a call to the Freeze() command).

Uppercase

Change the casing of a string to Uppercase in an edit text or a column (“my string” >> “MY STRING”)

UserQuery

[Legacy command] Enables you to activate a user query in the database.

WriteToEventLog

Write a message to the currently logged in users Event log (located in %appdata%\Boyum IT\BOY_USABILITY_X64\EventLogs)

 

TIP: If you want to temporarily not run part of a macro you can comment out the commands by using  //<command>. The command can also be used to document your macro if placed after a command.

Sample of a comment (Here command 4 – Set marked with // and will not be executed)

Activate (2053); //Activate A/R Invoice

Activate(1281); //Switch To Find Mode

Transfer($[$5.0.0]|$[$4.0.0]|STRING); //Transfer Item Code

//Set($[$[8.0.0]|*|STRING); //Set Star in Number to Do a Search All

Click($[$1.0.0]); //Click on the find Button