Dynamic Code Variables

Previous  Next |  Direct link to this topic

It is possible to have a Dynamic Code that before execution will ask for input before execution. This feature is called Dynamic Code Variables


You can ask for up to 20 variables using the [%0], [%1] ... [%19] syntax




What you do is to simple put the variable keyword as a placeholder for where you want your value to appear. You can use the same variable multiple times and in any order.


You then press the Variables button to define the individual variable's format







The variable you are defining the source for


The Source. It can a custom value or a list of common values like Business partners etc.

If can find the list of value you wish you also have the option to define a SQL sentence that should retrieve the values as a combo box.


The caption of the variable (The text shown when prompting the user for the value)

Source SQL

If you in the Source select SQL as source, you define the SQL here (else it is not used). The SQL sentence should be a SELECT statement with two selected columns. first value will be seen as the value of the selection and second will be seen as the description.


Sample: SELECT CardCode, CardName FROM OCRD

would result in a list of all Business Partners. CardCode will be the value for the customer select and CardName will be the description that help them choose the value.


The title of the window shown when prompting the user for the values



When you use the Dynamic Code it will instead of execution prompt you for the configured input




and once the OK Button is pressed the Dynamic Code will execute.


Tip: All Dynamic Codes use the same window to ask for their input. You might however want to use the B1 Validation System to validate the input before execution, but if you only did the validation on the FormType you would affect multiple configurations. For that reason a special Keyword $[$UFCODE.0.0] can be used to know what UF-Code create the input screen.


Important information about limitations and format:


All Dynamic Code variables are collected upfront and are not a blocking operation (technical limitation from the SDK) so you can as an example use Dynamic Code Variable to ask for missing data prior to pressing an Add button (the result would be that the Dynamic Code prompt would appear but SAP Business One would have already proceeded with the Adding on the business object).

Dynamic Code-prompt is a modal form so while on screen you can't go to any of the other screens in SAP Business One

Values that replace the Dynamic Code Variables keywords are formatted for usage in the SAP Gui. This means dates are in format yyyy-MM-dd and decimal values are use . (dot) as comma separator and no thousands separator. This mean that if you wish to display the input value to the user you need to format them using SQL:

A Dynamic Code vars prompt is not possible to confirm via Enter as normal (Technical limitation from SAP). You always need to use the Mouse to press the OK button.