Script Data Source¶
This data source executes a script and returns the result as a list of values.
The script data source enables the execution of custom scripts to dynamically generate data for form controls.
The script's result must be an array of objects, each defining the properties of an option within the list of values.
The script also supports asynchronous operations using async/await patterns. The script is expected to complete within a 500ms duration; otherwise, a progress dialog will be displayed to the user.
Example¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
In this example:
TextFormatis set to{{name}}, indicating that thenameproperty within each object returned by the script will be used for display text.ValueFormatis set to{{value}}, specifying that thevalueproperty within each object will be used as the underlying value.- The
Sourceelement contains theContentelement, which encapsulates the script to be executed. - The script is a simple JavaScript code block that returns a static array of two objects. Each object has
nameandvalueproperties, which will be used to populate the data source.
In summary, this data source will execute the provided JavaScript code, which will generate a list of two items. The first item will have a display text of "A" and a value of 1, and the second item will have a display text of "B" and a value of 2.
Async Support¶
In scenarios where scripts need to interact with external systems or invoke script modules to fetch data, asynchronous operations become essential to maintain a responsive user interface.
The script data source fully supports JavaScript's Promise object and the async/await syntax for asynchronously waiting on function calls. During the execution of such asynchronous operations, the user interface will display a loading progress indicator until the operation successfully completes. This prevents the UI from becoming unresponsive during potentially long-running data retrieval processes.
1 2 3 4 5 6 7 8 9 10 | |