Input and output data
Object context (available as an input parameter in platform scripts) is the main tool for interacting with the current form state. It allows you to retrieve parameters from the input map, read and modify component state, and invoke other services and validators.
Object methods context (Input)
Below is a list of methods available on the input object:
Retrieving script parameters
List<String> getParameters(final String name)– retrieves the list of values assigned to the given key from the input data map.String getFirstParameter(final String name)– retrieves the first element from the list for the given key. Returns"null"if there is no value.String getFirstParameter(final String name, final String defaultIfEmpty)– retrieves the first element from the list, and if it does not exist or is empty, returns the defined valuedefaultIfEmpty.Map<String, List<String>> getInputParameters()– returns the entire map of input data passed to the script.
Interaction with form components
String isVisible(final String id)– returns whether the component with the specified ID is visible.String getValue(final String id)– retrieves the current value of the component or session variable with the specified ID.String getData(final String id, final String attribute)– retrieves the value of a specific attribute for the component with the specified ID.void setValue(final String componentId, final String value)– sets the given valuevaluein the component with the specifiedcomponentId(the rule for providing the ID is the same as forgetValue).
Calling external services
List<Map<String, String>> callService(String name, Map<String, List<String>> input)– allows calling an external service (ServiceProxy).ValidatorOutput validate(String name, Map<String, List<String>> input)– allows calling a validator from the script.
Returning results (Output)
The result of script execution (e.g. when populating components) should be returned as an array. The platform supports this in two ways:
List of maps – the output array of objects is parsed into a list of maps, and then processed in the standard way by the calling component.
Single map – the return value is wrapped as a single-item list and processed in the standard way.
Usage examples
Populating the Value Select (Combobox) component
The script populates Value Select from a list (Combobox) based on the passed 'locale' parameter.
Outputs id, label, and description should be mapped to the appropriate Combobox fields, respectively id, text, and description.
Combobox-populating script:
Retrieving file names from the Attachments (UploadFile) component
The script uses the getData()method, which retrieves the value of a specific attribute for the component with the specified id. For the Attachments component, the names of added files are specified by the fileNames attribute and come from the request as a string in JSON format (e.g. ["name1.png", "name2.png"]), therefore it is necessary to convert this string into an object using the JSON.parse.
Retrieving the value of the Value Select from list (Combobox) in a Repeatable Section (RepeatableSection)
The script uses the getData()which retrieves the value of a specific attribute for the component with the specified id. For the Value Select the values (labels) of the given keys are specified by the label.
Last updated
Was this helpful?
