how to pass the parameter value of script include from workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 05:55 AM
Hi All,
I have the below script include and I use it from a catalog client script where I was able to pass a variable field value as parameter from client side.
I was thinking to re-use the same Script Include for another purpose which I need to use from Workflow because the return value is all I need to use.
However I am not sure how to pass the parameter value from Workflow.
Need help on the same.
TIA
var getAppname = this.getParameter('sysparm_app_name');//need help here
var getsysid = this.getParameter('sysparm_sysid');
var grgetCI = new GlideRecord('cmdb_ci_service');
grgetCI.addEncodedQuery('u_application_name!=NULL');
grgetCI.addQuery('u_application_name',getAppname);
grgetCI.query();
var CIlist = "";
while(grgetCI.next()){
if(CIlist == ''){
CIlist = grgetCI.used_for.toString();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 06:45 AM
Hi @DB1
So there is a concept of using client callable script include and server side script includes, first is meant to be called by client script and other by a server script and as we know worklfow uses server side, I'm afraid you will have to recreate the function in a new script include and call from workflow.
As there are security aspects to it, I would suggest the above approach.
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2023 06:28 AM
Hi, I am still stuck with it. If I have to create a new Script Include. What should I include or not from my script above. Could you please suggest?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2023 07:15 AM
Hi @DB1 ,
I trust you are doing great.
Here's an example of how you might refactor your Script Include:
var MyScriptInclude = Class.create();
MyScriptInclude.prototype = {
initialize: function() {
},
getCIList: function(appName, sysId) {
var grgetCI = new GlideRecord('cmdb_ci_service');
grgetCI.addEncodedQuery('u_application_name!=NULL');
grgetCI.addQuery('u_application_name', appName);
grgetCI.query();
var CIlist = "";
while(grgetCI.next()){
if(CIlist == ''){
CIlist = grgetCI.used_for.toString();
}
}
return CIlist;
},
type: 'MyScriptInclude'
};
Workflow's script activity:
var si = new MyScriptInclude();
var appName = /* retrieve your app name here */;
var sysId = /* retrieve your sysId here */;
var ciList = si.getCIList(appName, sysId);
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi