- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2015 07:24 AM
Hi All,
Can you anyone please let me know how to call script include from workflow.
Script include:
var HelloWorld = Class.create();
HelloWorld.prototype = Object.extendsObject(AbstractAjaxProcessor, {
helloWorld: function() {
var arr1 = this.getParameter('sysparm_user_name') ;
var values = '';
var array = arr1.split(',');
for(i=0;i<array.length;i++)
{
var the_choice = new GlideRecord('sys_user_grmember');
the_choice.addQuery('sys_id', array[i]);
the_choice.query();
if(the_choice.next()){
values = the_choice.user.user_name.getDisplayValue() + "," + values;
}
}
return values;
},
Thanks in advace
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2022 05:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2015 07:32 AM
Hi Kalyan,
Check out the worklfow, add a new run script activity and call something like this.
new ScriptIncludeName().functionName();
In the above scenario, the HelloWorld function cannot be callable from script include as it is written to accept parameters through AJAX.
You can modify the above script something like below,
var HelloWorld = Class.create();
HelloWorld.prototype = Object.extendsObject(AbstractAjaxProcessor, {
helloWorldAjax: function() {
var arr=this.getParameter('sysparm_user_name') ;
this.helloWorld(arr);
},
helloWorld: function(arr1) {
var values = '';
var array = arr1.split(',');
for(i=0;i<array.length;i++)
{
var the_choice = new GlideRecord('sys_user_grmember');
the_choice.addQuery('sys_id', array[i]);
the_choice.query();
if(the_choice.next()){
values = the_choice.user.user_name.getDisplayValue() + "," + values;
}
}
return values;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2015 07:37 AM
Hi Srinivas,
Thanks for the help.
In client script I have called with below script:
var a =g_form.getValue('UsersRemoved').split(',');
//alert(a);
var ga = new GlideAjax('HelloWorld');
ga.addParam('sysparm_name','helloWorld');
ga.addParam('sysparm_user_name',a);
ga.getXML(HelloWorldParse);
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
//alert(answer);
}
But now in workflow as well I need to get the field and run with Scriptinclude .
Can you suggest.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2015 07:39 AM
Hi Kalyan,
You can call the script include form the workflow as
new ScriptIncludeName().functionName();
Please let me know if you have any questions.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2015 07:48 AM
Basically you can fetch the field value on the workflow as
current.short; //Replace short with the exact field column name
For service catalog items you have to fetch the field value on the workflow as
current.variables.short; //Replace short with the exact name of the variable you have created.