This section will go into details of how the B1 Validation System Trigger works and give you various samples.
Data for test
In order to test the event you might like to test it yourself. The best way to do this is by creating the following two configurations
The above two configurations where we change the trigger-options of the B1 Validation configuration for each test will give you an idea of what goes on.
An overview
If we look at the SAP Business One Client in general we can see it as an interface that receive input from a user via a mouse and a keyboard, can we can see every little thing that the user does as a potential trigger.
The trigger system can be seen as filter of that certain user-actions we would like to add our additional functionality to, and configuring the B1 Validation System Trigger is taken these hundreds of events and specifying the ones we need.
The FormType, Item, Column, Row and MenuUid
First part of this filtering is the formtype, item column, row and MenuUid.
SAP Business One consists of thousands of windows but by entering the formtype of the window we would like to work on we do the first major filtering.
Next thing we filter by is what item we would like to work with. If we didn’t provide an item every single item of the whole window would trigger the event.
NB: A few events like Form Load AND FORM Unload should not contain an item but 95 % of all events should have the formtype/item combination.
If the item that you are working with is on line level you will have to provide the column that you are working with (else again ever of the lines columns would react to the trigger).
Last and most rarely user is the row-field. This can be used again to make the filter even more strict to say that as example that you only should react to the first of 10 rows.
Alternativ if event MenuClick is used Item, Col and Row are ignored for MenuUid which check if a specific menuUid is clicked.
Samples
Trigger
|
Result
|
|
Every place on the business Partner master data that we press receive the event
|
|
Now we reduce the event only to item 7 (The name field)
|
Form Mode
Next thing we can set is the form-mode
This makes it possible to have a trigger only work on a certain window-mode. We can choose between the 6 different combinations
Samples
Trigger
|
Result
|
|
Here we trigger in all modes.
Find-Mode:
Add-Mode:
|
|
Now we change FormMode to Add and we see the the event stop triggering in Find/OK/Update and so on but only in Add-mode
Add-Mode:
|
The different events
There are 19 types of events that are possible to catch
Event
|
Description
|
Click
|
This event happens before all other events and basically happens every time you press the left mouse (even before you release the button and even if you does not press a specific item or items that are not normally something you press (an label as an example)).
The click event is often confused with the much more common “item pressed” event.
|
Combobox select
|
This event happens when a combobox selection is made. This event will only trigger on comboboxes on header or line-level.
|
Double click
|
Double click is the same as the click event but if two clicks happens fast after each other.
Please note that you will still get the first click event since at that point the system is unable to know that you will click again
|
Form Load
|
Form load happens one time when opening the a window and will not happen more on that window.
NB: This event only need a formtype and not an item since it will never happen along with an item; only the form
Tip: This is most used by the Universal Function Content Creator.
|
Form Closing
|
Form Closing happens just before a window is about to be closed, but compared to form-closed happens before the windows is actually gone (This is handy if you want to prevent a window from closing)
NB: This event only need a formtype and not an item since it will never happen along with an item; only the form
|
Form Closed (Form Unload)
|
Form Unload it the equal to form load but happens instead when the window is closed.
This event is very rarely used.
|
Got Focus
|
This event happen when an edit text gets focus (aka it is marked with the yellow current field color)
|
Lost Focus
|
This event happens after a field is left. This is very similar to the more used Validate event, but the difference is that Lost Focus happens after you are out of the field (For that reason validation of entered data should not normally be Lost Focus but validate that happens just before you leave the field).
|
Item Pressed
|
This is the most often used event. The event happens when you press clickable items like buttons, tabs, checkboxes and linkedbuttons (Orange arrows)
|
Key Down
|
This event happens when a key is pressed (Use the Char Pressed and Modifier option for more on what key was pressed (ALT, CTRL or SHIFT))
|
Validate
|
This event is quite commonly used and happens when a field is about to lose focus (Often used when you want to trigger something based on what was entered in a field)
|
Menu Click
|
This event happens when a menu-item is pressed. This menu-item can be form the toolbar, main menu, top-menu or right-click menu.
NB: If you use a shortcut key like CTRL+F or F1 a menu-event it still fired.
NB: It is not possible to use a Menu click event without entering a MenuUid in the trigger
|
Data Load
|
This event sound similar to the Form Load but only happens once data is actually shown on the screen. Example if you open a Sales order a FormLoad will happen, but it is first when you navigate to an existing Sales Order that the Data Load event happens. Similar if you search or use a golden arrow to go to data a Data Load event happen.
|
Data Add
|
Similar to the Data Load event but happen everytime you add data to the screen (You press the Add-button and the data is saved)
|
Data Update
|
Similar to Data Add but when you update data
|
Data Delete
|
Similar to Data Add and Data Update but when data is removed (for the database, not simply switch to Find mode).
|
Column Link Pressed
|
Happens if you press a golden arrow on cell level
|
Column Picker Pressed
|
Happens if you press a picker (Choose From List, Calculator or Date-picker)
|
Choose From List
|
Happens when you choose from a choose from list
|
Form Key Down
|
Happens when a key is pressed but not item have focus
|
When B1UP is finished loading
|
As the name say, this event happen when B1 Usability Package is fully finished loading. This is handy if you wish some specific screen to be shown after startup.
|
There are tons of combinations here so please test this using your test-environment to see the different events in action.
Before Action, ActionSucess, Item changed, Inner Event and BubbleEvent
These 4 advanced options can each be set to true, false or ignore.
Option
|
Description
|
BeforeAction + ActionSuccess
|
The before action option and the Action Success properties, and let you determine when you wish to trigger the event compared to when SAP Business One react to the event.
Best way to describe it better is by sample so please see below
|
ItemChanged
|
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
|
InnerEvent
|
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. 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) |
Samples
NB: Please note that for these samples we need to change the test Universal Function slightly
The block event property is now checked (Needed by the Before Action sample)
Sample
|
Result
|
|
We here trigger clicking on the add-button in business partner.
If we click on the button we see that the event happen before SAP add the business partner and we block the event so the add does not happen
|
|
Now let us try to set the Before action to ignore and set Action success to true
Now if we click on the button we see that the event happen after SAP add the business partner (After the success of SAP Business Ones work)
|
|
Now let’s try something else. We are going to trigger validate of the customer name (Remember to set Before Action to false else we will be blocked and be unable to leave the field)
If we go to the name field, enter a name and exit the field we get the event
Now let just try to enter the name field again and exit it without changing the name.
Note that we get the same event.
|
|
Now let’s use the ItemChange option to True to change the above behavior
Now let just try to enter the name field again and exit it without changing the name.
Note that we get the event now.
Only if we enter the field, change the name and change it will we get the event.
|
Char pressed and Modifiers
Final part of the trigger is the char pressed and the Modifier. These are only used when you use the events "Key Down", "Form Key Down", "Item Pressed", "Double-clicked" (else they are ignored).
Basically what you can do is to enter the ASCII value of a keyboard char pressed and get an event for this.
NB: Please note that SAP itself uses a lot of keyboard shortcuts and in order for add-ons not to get in the way not every shortcut combination will work
Char Pressed Table
Key
|
Value
|
Key
|
Value
|
ENTER
|
13
|
C
|
99
|
TAB
|
9
|
D
|
100
|
BACKSPACE
|
8
|
E
|
101
|
SPACE
|
32
|
F
|
102
|
PAGEUP
|
33
|
G
|
103
|
PAGEDOWN
|
34
|
H
|
104
|
END
|
35
|
I
|
105
|
HOME
|
36
|
J
|
106
|
DELETE
|
46
|
K
|
107
|
UPARROW
|
38
|
L
|
108
|
LEFTARROW
|
37
|
M
|
109
|
DOWNARROW
|
40
|
N
|
110
|
RIGHTARROW
|
39
|
O
|
111
|
0
|
48
|
P
|
112
|
1
|
49
|
Q
|
113
|
2
|
50
|
R
|
114
|
3
|
51
|
S
|
115
|
4
|
52
|
T
|
116
|
5
|
53
|
U
|
117
|
6
|
54
|
V
|
118
|
7
|
55
|
W
|
119
|
8
|
56
|
X
|
120
|
9
|
57
|
Y
|
121
|
A
|
97
|
Z
|
122
|
B
|
98
|
|
|
Samples
Trigger
|
Result
|
|
Char Press 36 Equals the Home-button and item 5 is the code, so if you enter the code field and press the Home-key the event will trigger.
|
|
Now we modify the trigger to use the modifier CTRL so now the event only happen if you hold down CTRL key while
CTRL +
|
|