Argument | Description | Types / Required |
function | The name of the user-defined function. | string
required |
arguments | The arguments to the user-defined function. | object
not required |
The
Logic.invoke action executes a
user-defined function using runtime binding. The
function argument specifies the name of the function, and any arguments required by the function can be passed by specifying
arguments. Each of the
arguments object's names is matched with the name of a function parameter, and the value is bound to that parameter using the rules for
representing symbols in JSON.
Because logic functions can display UI elements, it is a good idea to use the
asynchronous version of this action when using this action from a
web view.
Functions can also be executed at runtime using the
Logic.eval action and the
invoke function.
The action returns the user-defined function's return value as a number or string.
The action throws an exception if any of its arguments are not specified in a valid form, or if:
- No function has the specified name.
- No argument is provided for a required function parameter.
- An argument cannot be converted from JSON to its logic version.
This example uses the asynchronous version of
Logic.invoke to ensure that the UI elements of the
List.show function call are displayed correctly.
<script>
const CS = new CSProActionInvoker();
CS.Logic.invokeAsync({
function: "QueryUser",
arguments: {
message: "Did you attend any of these universities?",
options: [
"Harvard University",
"University of Virginia"
]
}
})
.then(selection => {
console.log(`Selection was ${selection}.`);
})
.catch(e => {
CS.UI.alertAsync({
text: e.message
});
});
</script>
The logic function that is called by the above JavaScript: