Help me with Script include , it's returning null
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 12:26 AM
client script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var user = g_form.getValue('requested_by');
alert(user);
var ga = new GlideAjax('paccount');
ga.addParam('sysparm_name','getAccount');
ga.addParam('sysparm_user', user);
ga.getXML(classdemo);
function classdemo(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
g_form.setValue('project_account', answer);
}
//Type appropriate comment here, and begin script below
}
script include
var paccount = Class.create();
paccount.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getAccount: function() {
var value = this.getParameter("sysparm_user");
gs.info("PA" + sysid);
var accountname = "";
var gr = new GlideRecord('x_800355_corpora_0_employee');
gs.info("Hello" + gr);
gr.addQuery('sys_id', value);
gr.query();
if (gr.next()) {
gs.log("hello" + gr.project_account);
accountname = gr.getValue(project_account);
}
return accountname;
//return accountname.getDisplayValue();
},
type: 'paccount'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 09:05 PM
Hi @Vijay Kummamuru,
Please validate that you are calling exact backend name project_account. And also validate you are getting sys in of user in client side and try to get other field value.
Thanks
Jitendra

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 01:01 AM
Hi @Vijay Kummamuru ,
I checked your script there is one small error please use below script
var gr = new GlideRecord('x_800355_corpora_0_employee');
gs.info("Hello" + gr);
gr.addQuery('sys_id', value);
gr.query();
if (gr.next()) {
gs.log("hello" + gr.project_account);
accountname = gr.getValue("project_account"); // Please add string in project_account
}
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 06:17 AM
@Community Alums even i was able to pull value in background script , not sure why it is not working here @Jitendra Diwak1 even logs are not coming
Please find below screen shots and guide me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 11:47 AM
Hi @Vijay Kummamuru The script include is failing at line 6 at gs.info("PA"+sysid ) as you kept sysid (which is not defined in code ) .
Please remove line 6 info log (or) instead of using sysid use value and test the code . you will recieve all logs and code will work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 11:39 PM
Hi @Vijay Kummamuru ,
Here I am providing script to Auto Populate Callers Manager on Incident Form , you may follow the script to achieve your requirement.
Attaching screenshots for reference.
1.Client Script
2.Script Include
3.Output on Incident form.
Please mark my response as correct and helpful if it helped solved your question.
Thanks,
Rohit Suryawanshi