- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2020 09:00 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2020 03:27 AM
Hi All,
Finally the below setting worked:
var test = task.getDisplayValue(fieldBackEndName);
Thanks all for your prompt replies.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2020 11:04 PM
Hi,
Did you try to print what came in logs
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.info("Inside Script Include");
var test = task.fieldName.getDisplayValue();
return test;
}
},
type: 'scriptIncludeName'
});
what came in alert
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);
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2020 11:07 PM
Hi,
I am getting alerts pop up as:
1. Sys ID of the logged in user
2. Success
3. null
I am not getting value in logs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2020 10:54 PM
Hi,
try to make this change
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'
});
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2020 11:08 PM
Hi,
Not worked after making that change.
same as before.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2020 12:11 AM
Hi,
please compare with the script where it is working fine
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader