Script Include: Returning Null Value

kutvaram
Tera Expert

Hi All,

I have written an onLoad() Catalog Client Script where I used GlideAjax which is calling a script include.

Script Include has the simple glide record query where it fetches a date time field value based on the query result.

When I execute the script via background script, its returning the date time field value correctly.

But returning null value during onload() of the record producer.

What I am doing wrong in this?

Any help is much appreciated.

Thanks,

Ram Prakash K R

 

1 ACCEPTED SOLUTION

kutvaram
Tera Expert

Hi All,

Finally the below setting worked:

var test = task.getDisplayValue(fieldBackEndName);

Thanks all for your prompt replies.

View solution in original post

18 REPLIES 18

Hi Ankur,

Below are the Script Include and onLoad() Scripts:

 

Script Include Script:


var scriptIncludeName = Class.create();
scriptIncludeName.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

myFunction: function() {

var task = new GlideRecord("tableName");
task.addQuery("requested_for.sys_id=",this.getParameter('sysparm_user_name'));
task.query();
if(task.next()) {
gs.log("Inside Script Include");
var test = task.fieldName.getDisplayValue();
return test;
}
},
type: 'scriptIncludeName'
});


onLoad() Catalog Client Script:

function onLoad() {
//Type appropriate comment here, and begin script below

var userID = g_user.userID;
alert("Logged In User ID:" + userID);

var ga = new GlideAjax('scriptIncludeName');
ga.addParam('sysparm_name', 'myFunction');
ga.addParam('sysparm_user_name', userID);
ga.getXML(HelloWorldParse);

 

}

function HelloWorldParse(response) {
alert("Success");
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
g_form.setValue("variableBackEndName", answer);
}

try 

var test = task.getDisplayValue("fieldNameOfWhichYouWantData");

 

also are you getting that log in system logs?

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

Hi,

It didn't work.

also

task.addQuery("requested_for",this.getParameter('sysparm_user_name'));

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

Not worked