ExecuteStoredScript
- 2 Minutes to read
- Print
- DarkLight
- PDF
ExecuteStoredScript
- 2 Minutes to read
- Print
- DarkLight
- PDF
Article summary
Did you find this summary helpful?
Thank you for your feedback
Executes a script that has been stored by name on the DataJet server.
NOTE: To add a script to the DataJet Server, use Script Editor | File | Push and enter the name under which the script is be stored. To retrieve a stored script from the server, use Script Editor | File | Pull
Key | Value(s) | Description |
---|---|---|
method | ExecuteStoredScript | |
project | "currentprojectname" | Project name that is calling the Stored Script - automatically modified by Script Editor to equal Current Project - any value in here will be overwritten at run time. For this particular call, "project" has no effect. |
projectname | "sourceprojectname" | The name of the server project in which the script is stored
|
name | "scriptname" | The name of the script, as it is stored on the server. In this instance the following would be executed:
|
targetProject | "targetprojectname" | Optional. The name of the project that the stored script modifies. If not provided, projectname is used. NOTE: If calling ExecuteStoredScript by doing "Run Selected" in Script Editor, targetProject must match the current project or the "Project Has Changed instance" error will be returned. |
variables | { "%variable1%": "value1", "%variable2%": "value2", } | If the Stored Script has a defines section and makes use of variables, the variables can be passed via ExecuteStoredScript. In this example, the defines section of "scriptname" should contain %variable1% and %variable2%. See DEFINES for more details. Note that the variable key is not changed at run-time. So for example if the variable is defined in the following way in the defines section: { "key": "%myvariablename%", "value": "myvalue" } ...then... { "%myvariablename%": "%myvariablename%", } becomes the following at run-time: { "%myvariablename%": "myvalue", } |
debug | true/false | Optional. Default = false. If true, details of variables that were passed to the script will be output in the script log: |
realm | "realmname" | By default the current realm will be assumed. Use "global" to access scripts in the global realm. |
scriptId | "scriptId" | ID (alphanumeric), provided by executing program, used in conjunction with TrackScript and GetScriptResult to monitor progress on a script. If scriptId is not provided, DataJet server will automatically allocate a scriptid. |
authToken | "authorisedToken" | Only required for remote execution. Authenticated token, as returned from DJ access server. |
aSynchRequest | true/false | Added in v5.7.18 Allows asynchronous execution of stored scripts within DataJet Desktop- i.e., ExecuteStoredScript will return immediately rather than waiting for stored script to finish executing. (Use TrackScript to track status of an executing script) |
onThread | true/false | Added in v5.7.24 Allows asynchronous execution of stored scripts from outside of Datajet Desktop - i.e., ExecuteStoredScript will return immediately rather than waiting for stored script to finish executing. (Use TrackScript to track status of an executing script) |
forceCore | true/false | Optional. Default = false If true, will look to local script storage rather than ScriptHub |
{
"method": "ExecuteStoredScript",
"projectName": "SharedLibrary",
"name": "MyStoredScript",
"debug": true,
"targetProject": "ProjectToBeModified",
"variables": {
"%Variable1%": "value1"
},
"project": "CurrentProject"
}
The following is an example of a remote script execution using REST API. Note that a valid authorisation token is required. To monitor script status, see TrackScript.
curl
--location 'http://107.152.36.49:5555' \
--header 'Content-Type: application/json' \
--data '{
"method": "ExecuteStoredScript",
"projectName": "SharedLibrary",
"name": "MyStoredScript",
"debug": true,
"targetProject": "ProjectToBeModified",
"variables": {
"%Variable1%": "value1"
},
"project": "CurrentProject"
"authToken":"%AuthTokenHere%"
}'
The following will execute the script asynchronously using REST API (note "onThread":true) :
curl
--location 'http://107.152.36.49:5555' \
--header 'Content-Type: application/json' \
--data '{
"method": "ExecuteStoredScript",
"projectName": "SharedLibrary",
"name": "MyStoredScript",
"debug": true,
"targetProject": "ProjectToBeModified",
"variables": {
"%Variable1%": "value1"
},
"project": "CurrentProject"
"onThread": true
"authToken":"%AuthTokenHere%"
}'
The following will execute the script asynchronously from within explorer:
{
"method": "ExecuteStoredScript",
"aSyncRequest": true,
"scriptId":"1234hajsj328ed"
"projectName": "",
"name": "Demonstration Populated Load",
"targetProject": "",
"project": "Demonstration"
}
Was this article helpful?