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 12:46 AM - edited 06-13-2024 12:47 AM
Hi @Vijay Kummamuru,
Correct this below code
if (gr.next()) {
gs.log("hello" + gr.project_account);
//accountname = gr.getValue(project_account);
accountname = gr.getValue('project_account'); //You have to put the value in quotes
}
Please try this above code.
Please accept my solution if it works for you and thumps up.
Thanks
Jitendra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 04:22 AM
@Jitendra Diwak1 @Community Alums still getting Null

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 04:40 AM
Hi @Vijay Kummamuru ,
I tried your same script to incident table and it works for me please take reference from below script
var accountname = "";
var gr = new GlideRecord('incident');
gr.addQuery('sys_id', '46e482d9a9fe198101d3e3f3e2a14459');
gr.query();
if (gr.next()) {
gs.log("hello" + gr.number);
accountname = gr.getValue('number');
gs.log("accountname = " + accountname);
}
Result
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 04:44 AM
Hi @Vijay Kummamuru,
What you get in this log
gs.log("hello" + gr.project_account);
Thanks
Jitendra