Scripts can be created in the Formulate module and saved to the content manager. You can then inject those saved scripts into a Python or R scripting node. The shared script in Model can then be edited if required.
- Click here to learn about creating shared scripts in Formulate.
Configure a Shared Script
Inject a Shared Script
To inject a shared script to a Python or R scripting node, click the file icon (green highlight below) from the node's Properties.
The Script File Dialog will open; from here, navigate the folder tree to locate the required script. Only shared scripts in the same language as the scripting node, and to which you have access, will appear.
Click on the script to load it; the script will appear in the script window. A few functions will be exposed from the script window:
- Item Metadata: the Formulate icon will appear beside a hyperlink to the script. Hover over this expose the Item Metadata pop-up, which shows the script name, location in the content manager, create date, and user who created it (green highlight below). Click the hyperlink to open the script in Formulate; depending on the permissions you have for the script, you may be able to edit it.
- Detach: by default, the script in Model is linked to the script in Formulate, meaning that any changes made to the original will be automatically reflected in Model. Detach the script (red arrow below) in Model from the script in Formulate to make it a separate entity; any changes made from Formulate will not affect the script in Model. Continue reading below to learn more.
- Refresh: update the script with any changes that have been made from Formulate (yellow arrow below).
The scripting environment that a linked script is run in is set from the Formulate module, and cannot be changed from Model. If no environment was selected, or if you want to change the environment, this must be done by editing the script in Formulate.
However, if your detach the script from its instance in Formulate, you will be able to change the scripting environment for the detached script in Model. Continue reading below to learn about detaching a script.
- Click here to learn more about scripting environments.
Inputs and Outputs
Inputs and Outputs may or may not have been configured for the script in Formulate; if they were configured, they will be loaded into the Input and Output windows in Model.
However, the 'From' field (which determines which column is fed into the script) cannot be set from Formulate. This is because scripts build in Formulate are not associated with any database. The From field for each column must therefore be set in Model.
You can also edit, add, or delete inputs and outputs as needed.
- Click here to learn more about inputs and outputs.
Detaching a Script
A shared script that is injected into a scripting node is still linked to the script object in Formulate; it is a single content item that can be used in multiple locations. This means that any changes made to the script in Formulate are automatically reflected in the script in Model.
However, you can make changes to the script and its inputs and outputs in Model without affecting the script item in Formulate.
You can detach the script in Model from the script content item in Formulate; in this scenario, changes made to the script in Formulate will not affect the script in Model. You will also be able to change the scripting environment for the script in model, if the script is detached.