Script Include not returning value

anilkumarkarams
Mega Contributor

Hi,

Can aynone help me out in identifying the error in the following code? My expectation is function should return value , but it is returning value

var IreturnInc = Class.create();

IreturnInc.prototype = Object.extendsObject(AbstractAjaxProcessor, {

  IreturnInc : function()

  {

  var incref = new GlideRecord('incident');

  incref.query();

  if(incref.next())

  return incref.number;

  },

      type: 'IreturnInc'

});

Please help.

Regards,

Anil Karamsetty

1 ACCEPTED SOLUTION

Thanks All for your Coordination. Code is working now. but surprisingly i did not make any changes to the code , i copied the code from my post and pasted in demo instance.


View solution in original post

11 REPLIES 11

anilkumarkarams
Mega Contributor

My Client Side Script is



function onLoad() {


    //Type appropriate comment here, and begin script below


  var ga = new GlideAjax('IreturnInc');


ga.addParam('sysparm_name','IreturnInc');




ga.getXML(HelloWorldParse);



function HelloWorldParse(response) {


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


    alert(answer);


}


   


}


Hi Anil,



This is working fine for me.   Can you please make sure that you marked the Client callable field with a check mark on the Script Include.   Without this you will receive a null value.


Hi Travis,



It was already enabled. May be their is something wrong with the code.



Regards,


Anil


Hi Anil,



What instance version and browser version are you running?   I have tried this in Fuji with Safari and Firefox without an issue and without any changes to code.



The two things that you can check in the mean time (I check for these an occasionally find issues):



1.   Change the return in your script include to be return incurred.number + '';   This forces a string conversion which shouldn't be an issue but for some scripts it does cause problems.



2.   Check in your browser console to make sure that responseXML is being returned as an object.   You can do this by adding a console.log(response.responseXML); statement in your HelloWorldParse callback.   Some browsers choke on this one for some reason.