Workflow error : ' GlideAjax is not defined'

abhiyadav2001
Giga Expert

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';}

}

1 ACCEPTED SOLUTION

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.


View solution in original post

10 REPLIES 10

Hi Harish,



below is my script include code..



checkifManager:function() {


              gs.log('*********************************************************************');


              var userName = this.getParameter('userName');


                              var groupName     = this.getParameter('groupName');


                              var isManagerofGroup = false;  


             


                              var result = this.newItem("result");


              result.setAttribute("message",isManagerofGroup );


                             



                                return isManagerofGroup;


             


      }





I am not aware if we could add parameters to the function, tried using as below.


checkifManager:function(userName, 'groupName){


// rest of the code


}



also I called the method from workflow as,



var result = verify.checkifManager(current.userName, current.groupName);




Am I going in a right direction?



Thanks,


Abhijeet


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.


Hi Harish,



That worked perfect for me ! Thanks a ton !



regards,


Abhijeet


Your welcome Abhijeet .


Hello Harish,



How would you bring the value returned in the Script Include back into the workflow script?



I know that a client script would normally use something like ga.getXML(setSomething) and then have something like the following:



function setSomething(response) {


      var answer = response.responseXML.documentElement.getAttribute("answer");


      answer = answer.toString();


}



What would be different when using gs.include()?



Thank you,


Mel