Write Script
Description
The write_script part allows you to have the system execute a JavaScript/jQuery.
Use
You can use the write script part in a node to execute JavaScript/jQuery at any point in the application.
NOTE: With the write_script client script part you can have your application execute in the browser JavaScript modeled in a logicnet. You must use this part must be used carefully, however, as it possible to make mistakes and introduce XSS vulnerabilities: https://owasp.org/www-community/attacks/xss/.
When you use this part you must make sure that all data inserted into the script using $(..) is properly encoded.
- For strings, you should call the JavaScript encode method myfunction("$(encode_js(…))").
- A JSON-encoded string should not be JavaScript-encoded when used directly in a data object: var json=$(json_str).
- If you use JSON.parse, data must be JavaScript-encoded using JSON.parse("$(encode_js(json_str))").
Editor Fields
Field Name | Description/Use | Type/Options | Optional/Mandatory |
Javascript | This is the name of the JavaScript the system should execute. | Text | Mandatory |
Mode | Read: The system executes the JavaScript in the read cycle of the node. Write: The system executes the JavaScript in the write cycle of the node. Note: Some nodes don't have a write cycle; for example, the process node. So combining the write_script part in a process node with mode set to 'Write' won't work. |
Read | Write | Mandatory |
Skip interpolation | Unchecked: This means the system will interpolate. Checked: This means the system will not interpolate. |
Checkbox | Mandatory |
Escape jQuery | This is only required when Skip interpolation is unchecked. Unchecked: The system will not escape the jQuery code, so $() will be seen as an interpolation instead of jQuery. Checked: The system will escape the jQuery code, so $() will be seen as jQuery instead of as an interpolation. |
Checkbox | Optional |
Example
Please download and import the following example project in your workspace.