{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":1056,"path":"api-reference/server-api-reference/c_JavascriptProbeAPI.md","title":"JavascriptProbe - Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# JavascriptProbe- Global\n\nThe JavascriptProbe script include provides methods for using the JavascriptProbe on the MID Server.\n\nUse these methods in server scripts to send a probe to the MID Server For more information, see [Create a JavaScript Probe activity](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/servicenow-platform/t_CreateAJavaScriptProbeActivity.md).\n\n**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)\n\n## JavascriptProbe - JavascriptProbe\\(String midServer\\)\n\nCreates an instance of the JavascriptProbe.\n\n|Name|Type|Description|\n|----|----|-----------|\n|midServer|String|The MID server name|\n\nThe following example shows how to use an instance of JavascriptProbe.\n\n```\nvar jspr = new JavascriptProbe('midserver_name');\n\nvar func = function () {\n    // Java FileWriter class of java.io package. FileWriter is write data in character.\n    var FileWriter = Packages.java.io.FileWriter;\n\n    // Constructs a FileWriter object given a file name.\n    var file = new FileWriter(\"TestMessage.txt\");\n\n    // Gets the parameter from the ECC queue payload.\n    var message = probe.getParameter(\"message\");\n\n    // Write the message to a file.\n    file.write(message);\n\n    // Close the FileWriter.\n    file.close();\n    file = null;\n}\n\n// Add parameter to pass to MIDServer.\njspr.addParameter('message', 'ServiceNow Message');\n\n// Set the script to be executed by the MIDServer as a string\njspr.setJavascript('(' + func.toString() + ')();');\n\n// Send to MIDServer. The MIDServer will execute the Script immediately.\njspr.create();\n```\n\n## JavascriptProbe - addParameter\\(String name, String value\\)\n\nAdds a parameter with the specified value to the probe.\n\n|Name|Type|Description|\n|----|----|-----------|\n|name|String|The parameter name|\n|value|String|The parameter's value|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar jspr = new JavascriptProbe('msserv');\njspr.setName('jsprobe100');\njspr.setSource('jspr_source');\njspr.addParameter('support_feat', 'yes');\n```\n\n## JavascriptProbe - create\\(\\)\n\nCreates the probe for the current MID server, puts it on the output queue, and sets its state to \"ready\".\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar jspr = new JavascriptProbe('msserv');\njspr.setName('jsprobe100');\njspr.setSource('jspr_source');\njspr.setJavascript('jspr_script');\njspr.create();\n```\n\n## JavascriptProbe - setJavascript\\(String script\\)\n\nAdds a script to the probe.\n\n|Name|Type|Description|\n|----|----|-----------|\n|script|String|The script to add to the probe|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar jspr = new JavascriptProbe('msserv');\njspr.setName('jsprobe100');\njspr.setSource('jspr_source');\njspr.setJavascript('jspr_script');\n```\n\n## JavascriptProbe - setName\\(String name\\)\n\nSets the name of the JavascriptProbe\n\n|Name|Type|Description|\n|----|----|-----------|\n|name|String|The name to give the JavascriptProbe.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar jspr = new JavascriptProbe('msserv');\njspr.setName('jsprobe100');\n```\n\n## JavascriptProbe - setSource\\(String ip\\)\n\nSets the source of the probe.\n\n|Name|Type|Description|\n|----|----|-----------|\n|ip|String|The IP address of the target probe.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar jspr = new JavascriptProbe('msserv');\njspr.setName('jsprobe100');\njspr.setSource('100.100.100.1');\n```\n\n"}}