Transactions offer automatically in their forms a prompt or selection list for each foreign key, by pressing the arrow icon offered aside each Foreign Key. They also offer another prompt by pressing the magnifying glass icon offered in the form above all. Similarly, when editing in an SD application an element previously selected from the List of a Work With <Transaction>, a prompt will be offered on each FK attribute. That is, each WorkWithDevices<Transaction> offers in its Section(General)/Edit Layout prompts for each FK.
The prompt rule allows changing a default prompt automatically called in a transaction or WWSD Section(General)/Edit layout, and also allows invoking a prompt for a secondary attribute or a variable, to help the user with the selection of a valid value.
If the Prompt references several out parameters, at least one of them must be enabled in the Form; otherwise the Prompt rule will not be enabled.
Prompt(objectName, parmx [, parm1, .... , parN]) [ on ctrl ] ;
It's the name of the called object (it must be a Web Panel, SD Panel or Work Panel, returning at least a parameter).
It's the attribute or variable for which the user needs to select a value through the prompt. If it is a compound foreign key, you have to specify the attributes that compose the foreing key separated by a comma.
parm1, .... , parN
Optional parameters that can be sent to the called object (and must be received there) for some purpose (I.e: for filtering in the prompt and showing only certain records that fulfill with a condition).
Is the control associated to the prompt.
If the attributes indicated as parameters compose a foreign key and there is an automatically generated prompt based on this foreign key, the object indicated in the prompt rule is called instead of the prompt generated by GeneXus.
As the syntax shows, the Prompt rule allows you to (optionally) specify a Web or SD interface, the name of the control associated to the specific prompt you want to call. The possible controls for web are those which have the link property (TextBlock, Image, etc.). For Smart Devices, the possible controls are the ones that can have an associated Tap Event.
If ‘on Ctrl’ is omitted, an image, button, etc. will be added (in the corresponding environments) to the right of the field(s) with prompt, as it has occurred so far.
Use of prompts on foreign key attributes
Form: a grid with Base Table CUSTOMER, necessarily containing the CustomerId attribute (either visible or invisible).
&CustomerId = CustomerId //the selected value is charged in the parameter to be returned
Note: This example shows the prompt rule applied to a Transaction, but it can be used in a Web Panel. Suppose you define a variable &customerId with the same data type as CustomerId. If you specify in the Web Panels Rules section:
prompt( CustomerSelection, &customerId);
the prompt icon will be displayed next to the variable in the form, allowing the user to select the customer from the CustomerSelection object.
The attribute, StudentGender, is not a foreign key, but it must comply with its defined value range ('F' / 'M'). The Web Panel 'GenderSelection' displays the two possible values, and either value can be selected. This prompt is activated when you press the icon offered aside the attribute StudentGender.
Similarly, having the Panel for Smart Devices 'GenderSelection' and the above prompt rule in the Rules section of the WorkWithDevicesStudent/Section(General)/Edit layout, when trying to insert/modify a student through this layout at runtime, the StudentGender attribute will have the possibility to activate the 'GenderSelection' prompt in order to select the desired one.
Note: These examples show how to use the prompt rule on a non-FK attribute inside a Transaction or WWSD Section(General)/edit. But the same can be done using a variable (&gender) in a Web Panel or Panel for Smart Devices, to be loaded from the called prompt object.
The Prompt rule does not execute server side events (Web Panels: Start event, Refresh event and Load event; Transactions: Start event and Exit event), except that it uses parameters encryption (Encrypt URL parameters property). When encrypting parameters, server side events are executed.