- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2014 03:41 AM
Hi,
I am calling a 'script include' in workflow. Script is marked as 'client callable'. This workflow is attached to 'Catalog item'.
When I create a request and check workflow, SNow is showing me an error message ; 'GlideAjax is not defined'.
Below is my code.. I dont know what am I missing here ?
// This script needs to set answer to 'yes' or 'no' to indicate the state of the activity.
//
// For example,
//
// answer = ifScript();
//
// function ifScript() {
// if (condition is true) {
// return 'yes';
// }
// return 'no';
// }
isManager();
function isManager(){  
        var ga = new GlideAjax('verifyIfManager'); // script include name
ga.addParam('sysparm_name', 'checkifManager') // function name to be called
ga.addParam('sysparm_userName', groupList); // parameter
ga.addParam('sysparm_groupName',userGroup); // parameter
ga.getXML(parseAnswer);     } // response
// response function
function parseAnswer(response) {
var result = response.responseXML.getElementsByTagName("result");
var message = result[0].getAttribute("message");
if (message) { return 'yes' ;}
else { return 'no';}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2014 05:45 AM
Hi Abhijeet,
Dont pass the parameters. You can write current.current.userName in includescript .
Wite this below code in Workflow.
Workflow
_____________
gs.include("verifyIfManager");
var verify = new verifyIfManager();
var result = verify.checkifManager();
Write this below code in includescript
_____________________________
checkifManager : function(){
var userName = current.username;
var groupName = current.group_name;
write your code according to your requirement
return answer;
}
Regards,
Harish.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2014 03:42 AM
I also tried removing 'new' in Glide Ajax call.. Its throwing the same error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2014 03:46 AM
function isManager(){  
        var ga = new GlideAjax('verifyIfManager'); // script include name
ga.addParam('sysparm_name', 'checkifManager') // function name to be called
ga.addParam('sysparm_userName', groupList); // parameter
ga.addParam('sysparm_groupName',userGroup); // parameter
ga.getXML(parseAnswer);     } // response
// response function
function parseAnswer(response) {
var result = response.responseXML.getElementsByTagName("result");
var message = result[0].getAttribute("message");
if (message) { return 'yes' ;}
else { return 'no';}
}
Above function is written in script include ?
Please don't use GlideAjax in Script include, it is a client callable function in the sense you have to use this function only in Client script.
To call script include through workflow, you have to follow the below steps,
var call_script= new verifyIfManager();
call_script.isManager();
Thanks,
Anish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2014 06:20 AM
Hi Anish
That was really helpful.
Thanks,
Abhijeet

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2014 03:57 AM
Hi Abhijeet,
You can call Inclidescript in workflow in below format only.
gs.include("verifyIfManager");
var verify = new verifyIfManager();
var result = verify.checkifManager();
In includescript you can directly get parameters by current.groupList
Regards,
Harish.