--- title: "ExecuteScript" slug: "executescript" updated: 2023-07-27T10:44:18Z published: 2023-07-27T10:44:18Z canonical: "docs.datajet.app/executescript" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.datajet.app/llms.txt > Use this file to discover all available pages before exploring further. # ExecuteScript Executes an embedded DataJet JSON script or a DataJet JSON script file. | Key | Value(s) | Description | | --- | --- | --- | | method | "ExecuteScript" | Executes the provided script | | project | "CurrentProjectName" | The name of the current project | | script[] | [ {method1}, {method2}, {...} ] | If "script" is provided, "scriptfilename" is not required. Either "script" or "scriptfilename" must be provided. | | ignoreErrors | true/false | Default = false. If true, will continue executing methods even after an error is encountered. | | sample | true/false | Default = false. If true, load methods such as CreateTableFromFile will load only a sample of data. See | | targetProject | "NameOfProjectToModify" | | | scriptId | "UserDefinedScriptID" | Optional. The script ID to use to reference the script. If not provided, an ID will be generated. Script Ids of executed scripts can be see in Desktop \| Script \| History | | contacts[] | [ {email1@domain1}, {email2@domain2}, {...} ] | Optional. List of contacts to send script result to by email. | | scriptFilename | "PathAndFileOfScript" | If "scriptFilename" is provided, "script" is not required. Either "script" or "scriptFilename" must be provided. | | logFilename | "PathandFileForLogData" | Location of logfile. | | *filename* | *"PathAndFileOfLogData"* | *Deprecated. If "filename" is provided, and no "logfilename" is provided, log data will be output to "filename"* | | variables{} | [ {"variable1":"value1"}, {"variable2":"value2"} {...} ] | If the Stored Script has a defines section and makes use of variables, the variables can be passed via ExecuteScript. 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: ![](https://cdn.document360.io/73b6469b-c1e4-47e9-aa65-986c8ebd17ca/Images/Documentation/image-1684491662687.png) | | quiet | true/false | Optional. Default = true. If false, ScriptEditor will not log to Mongo. | | aSynchRequest | true/false | Added in v5.7.18 Allows asynchronous execution of stored scripts within DataJet Desktop- i.e., ExecuteScript will return immediately rather than waiting for 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., ExecuteScript will return immediately rather than waiting for script to finish executing. (Use TrackScript to track status of an executing script) | The following is the blank JSON method: ```json { "method": "ExecuteScript", "project": "", "script": [ {} ], "ignoreErrors": false, "sample": false, "targetProject": "", "scriptId": "", "contacts": [], "logFilename": "", "scriptFilename": "", "quiet": false, "debug": false, "variables": {} } ``` The following shows a populated ExecuteScript method where script information is contained in the "script" element: ```json { "method": "ExecuteScript", "ignoreErrors": false, "sample": false, "scriptId": "", "script": [ { "method": "DeleteField", "name": "cluster", "table": "customer", "project": "RegressionDB" }, { "method": "DeleteFromCollection", "name": "MF Profile cluster", "type": "DJExplorer.MFProfileControl", "collection": "REPORTS", "project": "RegressionDB" }, { "method": "Export", "exportHeaders": false, "urns": false, "quotedStringHeaders": true, "overwrite": true, "tabDelimited": true, "createImportScript": false, "fields": [ "customer.age", "customer.income" ], "dataSet": { "logic": "or", "name": "SubSet", "strict": true, "set": [ { "logic": "or", "stype": "TABLE", "entity": "customer" } ] }, "exportFilename": "%DATAPATH%age_income.txt", "project": "RegressionDB" }, ], "targetProject": "RegressionDB", "project": "RegressionDB" } ``` This example will execute the script denoted by scriptFilename: ```json { "method": "ExecuteScript", "ignoreErrors": false, "script": [ { "project": "BikeData2" } ], "sample": false, "scriptId": "", "scriptFilename": "%DATAPATH%TestExecuteScript_Child.json", "quiet": false, "debug": false, "project": "BikeData2", "targetProject": "BikeData2" } ```