Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to call Mid Server Script File from workflow?

Anshul12
Tera Contributor

I have a Mid Server Script File, which I need to call in a workflow. How can I do that?

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you create mid server script include and invoke it in this way

JAVASCRIPTPROBE AND MID SERVER SCRIPT INCLUDES

https://community.servicenow.com/community?id=community_question&sys_id=7ca6323bdbdee340656a5583ca96...

var jpr = new JavascriptProbe('<name of the mid server>');
jpr.setName("testcopypoc");
jpr.setJavascript("var req = new cpy(); req.prnt();");       //cpy1 is mid server script include name and prnt is the function in include
jpr.addParameter("<parameter>", '');   //if you want to pass parameter to mid server
jpr.addParameter("skip_sensor", true);
jpr.create();

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

And we can use this script to include in the run script, right?

Hi,

yes the above sample code I shared you can write that in workflow run script

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

So Is there any possible way that I could use my Mid Server Script File in the Mid Server Script Include?