The Trigger System

Previous  Next |  Direct link to this topic

The trigger system is a pseudo-code configuration built on top of the SAP SDK, which allows on-the-fly triggers of the SDK’s Item Events. It allows you to define what form things happen on, which controls are involved, and so on.

 

image098

Field

Description

Form type

Use this field to decide which form types (Window types in SAP Business One) the trigger should react to.

TIP: IF YOU HAVE EXACTLY THE SAME CONFIGURATION ON TWO OF MORE FORMS (OFTEN SALES AND PURCHASE ORDERS) YOU CAN MAKE ONE CONFIGURATION WORK ON MULTIPLE FORMS BY ENTERING MULTIPLE FORM TYPES SEPARATED BY ;. EXAMPLE: IF YOU ENTER 139;133 AS FORM TYPE THE TRIGGER WILL REACT ON BOTH FORM TYPE 139 (SALES ORDER) AND 133 (A/R INVOICE).

TIP: ENTERING -1 WILL MAKE IT RUN ON ALL WINDOWS.

TIP: USE THE “..” BUTTON TO CHOOSE BETWEEN THE MOST COMMON FORM TYPES.

Item

In this field, you enter which item the trigger should respond to. This could be a button (Being pressed), an Edit Text (Leaving the field) or a combo box (new value selected) or any of the items on a window. Some events – like form-load and form-unload – does not require an item

TIP: IF YOU HAVE EXACTLY THE SAME CONFIGURATION ON TWO OF MORE ITEMS YOU CAN MAKE ONE CONFIGURATION WORK ON MULTIPLE ITEMS BY ENTERING MULTIPLE ITEMUIDS SEPARATED BY ;. EXAMPLE: IF YOU ENTER 4;54 AS ITEMUID ON A SALES ORDER THE TRIGGER WILL REACT ON BOTH THE BP CODE ITEM (4) AND BP NAME ITEM (54)

Column

If the item above entered was a matrix or a grid, you will also need to tell the trigger which column it is that you want to react to. If the item is not a matrix, you should not provide a column.

TIP: IF YOU HAVE EXACTLY THE SAME CONFIGURATION ON TWO OF MORE COLUMNS YOU CAN MAKE ONE CONFIGURATION WORK ON MULTIPLE COLUMNS BY ENTERING MULTIPLE COLUMNUIDS SEPARATED BY ;. EXAMPLE: IF YOU ENTER 1;3 AS COLUID ON A SALES ORDER WITH ITEM 38 THE TRIGGER WILL REACT ON BOTH THE ITEM CODE (1) AND DESCRIPTION (3)

Row

Again, if the item chosen is a matrix, and you have defined a column, you can choose to decide which specific row the trigger should react on. If you wish to react on any row then leave the row-field empty

Menu Uid

Here you can enter the Menu Uid of the menu item clicked (Only used in combination with the Menu Click Event (See below))

TIP: IF YOU HAVE EXACTLY THE SAME CONFIGURATION ON TWO OF MORE MENU ITEMS YOU CAN MAKE ONE CONFIGURATION WORK ON MULTIPLE MENU ITEMS BY ENTERING MULTIPLE MENUUIDS SEPARATED BY ;. EXAMPLE: IF YOU ENTER 1281;1282 AS MENUUID ON A SALES ORDER, THE TRIGGER WILL REACT ON BOTH THE ‘SWITCH TO ADD’ (1282) AND ‘SWITCH TO FIND’ (1281)

TIP: USE THE “..” BUTTON TO CHOOSE BETWEEN THE MOST COMMON MENUUIDS.

Above, you have defined what specific form/item/column/row the system should react on. In addition to this you now need to tell the trigger the specific state the form/item is in and what event-conditions is required.

Form Mode

The form-mode allows you to only get the trigger to react if the window is in a specific mode. As an example you might only want to react to a button being clicked in add-mode.

Event

The event is the primary selection of the state in the trigger. Here you inform the trigger of what kind of event happened

Event

Description

Click

Any item was clicked but not pressed (See item pressed)

Combo box select

A value was selected from a combo box

Double click

An item received a double click (two fast left clicks)

Form Load

A window was opened (Please note that in some cases Form Load cannot access the window opened (since it is still opening))

 

NB: This event can't be used on other Add-on screens (Even if they have the B1UP Integration code)

Form Closing

A window is about to be closed. If you catch this event BeforeAction and block the event you can prevent the user from closing the window.

Form Closed (Form Unload)

A window was closed (Please note that since the Form Unload closes the window, in some situations you will not be able to access the data from that window where the event happened.)

Item Pressed

An item was pressed (pressed = clicked and released button) [This is the most commonly used event in configurations]

Key Down

A key was pressed (Use the Char Pressed and Modifier option for more on what key was pressed (ALT, CTRL or SHIFT))

NB: This event is not supported in Browser Access

Validate

A field is about to lose focus [Often used when you want to trigger something based on what was entered in a field]

Got Focus

This happens when a field have received focus

NB: WHEN USING GOT FOCUS, BE AWARE THAT THIS DOES NOT HAPPEN BEFORE ACTION, SO SETTING THIS PROPERTY TO TRUE WILL NEVER TRIGGER THE EVENT

Menu Click

This happens when a menu click is pressed (the menu Uid you written in the menu Uid field)

Data Load

When a window load its data (Example – When you navigate to a new Business Partner)

Data Add

When a window add some data (Example – When you add a new Business Partner)

Data Update

When a window updates its data (Example – When you update a Business Partner)

Data Delete

When a window deletes its data (Example – When you delete a Business Partner)

Item Pressed + Combo box Select

This event is a combination event that catch both Item Pressed and Combo box Select. This is handy in SAP Business One 10 where you have the "Add & New", "Add & View" and "Add & Close" button that require you to react to both types of events.

clip0215

Column Link Pressed

When a user presses an Orange Arrow on line level this event will happen. NB: On to catch arrows being pressed on header level, please use the normal Item Pressed

Column Picker Pressed

When a user press one of the picker icons on line level this event will happen. Here are the different pickers you can react to:

image099

Choose From List

Happens after you choose a value in a Choose from List window (Example the List of Business Partners)

image101

NB: ONLY FIELDS IN THE SYSTEM WITH A CHOOSE FROM LIST (ABILITY TO PRESS TAB) WILL TRIGGER THIS EVENT. NORMAL FIELDS AND UDFS WILL NOT TRIGGER SUCH AN EVENT.

NB: PLEASE NOTE THAT THE EVENT HAPPENS BEFORE THE VALUE IS ACTUALLY ON THE SCREEN. USE VALIDATE INSTEAD IF YOU WISH TO ACTUALLY WISH TO USE THE CHOSEN VALUE

Form Key Down

Happen if you press a key on a window without having any item in focus.

NB: This event is not supported in Browser Access

FORM_RESIZE (Advanced)

Event that happen every time you resize a form.

NB: ANY USES OF THIS EVENT IS PREMIUM SUPPORT

When B1UP is finished loading

This event happen only once after B1UP are successfully started. You can use this event to open some predefined window as an example.

Below are the four event-options you can use to specify the event even further. This is needed because SAP almost always sends its events twice (One before SAP does what it was supposed to do on the event and one after it is done with the event). These all have 3 states (True, False and ignore (react on both True and False)).

Before Action

This determines if your trigger should react before SAP reacts on the event.

 

NB: SOME EVENT DO NOT HAVE AN EVENT WHERE BEFORE ACTION IS TRUE.

NB: ONLY EVENTS THAT IS SET BEFORE ACTION CAN BLOCK SAP’S EVENTS USING ITS UNIVERSAL FUNCTION

Action Success

This determines if your trigger should react after SAP is done processing the event.

Item Changed

This determines if you only want to react to the event it the item of the event was changed.

 

Warning: Due to SAP Limitations the "Item Changed = true" will never happen on fields that are bound to a Choose From List so it can't be used on such fields

Inner Event

Inner Events are SAP-generated events that which are not normally expected.  For example, inner events can occur when more than one Validation definition has the same trigger settings.  Sometimes, this can lead to an endless loop of events which may cause errors indicating 'The RPC server is unavailable' in the B1UP Eventlog. The InnerEvent setting provides a filter which can be used to determine if the Validation's Condition should execute for events that are not anticipated.  The values of this setting are:

 

When the Event is an Inner Loop (setting=True)

When the Event is not an Inner Loop (setting=False)

Do not filter this Validation on whether or not the Event is an Inner Loop (setting=Ignore)

 

It is usually best to set InnerEvent set to False when the Event is set to Validation and to set it to Ignore for other Events.  In some rare cases you might need to change it.

Bubble Event

Because multiple add-ons can run at the same time and multiple B1 Validation can also run in the same manner you might have the need to run config number one but that this conditionally block the event run. In such a case 2 scenarios are eaqually valid.

-Either you want to run the second config anyway (Bubble Event = true or Ignore)

-You do not want the second event (Bubble Event = false)

If the event chosen was the Key Down event, you will need to tell the trigger what key you would like it to react on. This is done using the Char Pressed and the Modifier

Char Pressed

The ASCII Code of the key that was pressed (Decimal value).

List of common ASCII Codes

ENTER = 13, TAB = 9, BACKSPACE = 8, SPACE = 32, PAGEUP = 33, PAGEDOWN = 34, END = 35, HOME = 36, DELETE = 46, UPARROW = 38, LEFTARROW = 37, DOWNARROW = 40, RIGHTARROW = 39, 0 = 48, 1 = 49, 2 = 50, 3 = 51, 4 = 52, 5 = 53, 6 = 54, 7 = 55, 8 = 56, 9 = 57, A = 97, B = 98, C = 99, D = 100, E = 101, F = 102, G = 103, H = 104, I = 105, J = 106, K = 107, L = 108, M = 109, N = 110, O = 111, P = 112, Q = 113, R = 114, S = 115, T = 116, U = 117, V = 118, W = 119, X = 120, Y = 121, Z = 122

TIP: USE THE “..” BUTTON TO CHOOSE BETWEEN THE MOST COMMON CHARPRESSED VALUES.
 

Warning: Some key combinations are not supported. It is not something we filter out and it's all controlled by SAP. There is no fixed list of what is not supported (SAP could technically from patch to patch reserve new variations)

Modifier

The modifier-key that was used while pressing the key (CTRL, SHIFT, ALT, and so on)

Prevent event looping

This option will in advanced setups make you able to prevent that one validation trigger another that then triggers the first again (endless event deadlock that cause SAP to crash). It is recommended that you default leave this on unless you are making some very funky events J

For more details on the trigger system, please see the detailed trigger samples