- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2019 10:50 PM
Not able to display value from script include
Please let me know what is wrong with the below code
I tried in background script with gs.print it worked
var HelloWorld = Class.create();
HelloWorld.prototype = Object.extendsObject(AbstractAjaxProcessor, {
helloWorld:function() {
var user_sysid = this.getParameter('sysparm_user_name');
gs.addErrorMessage( user_sysid); ----------------------- working
var getRecord = new GlideRecord('sys_user');
getRecord.query('sys_id',user_sysid);
getRecord.next();
var printvalue= getRecord.user_name;
gs.addErrorMessage(printvalue); ------------ not working
gs.log("print value "+printvalue); -------------- not working
return printvalue;
} ,
});
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2019 10:59 PM
Hi Suprakash,
Try adding if condition like below :
var HelloWorld = Class.create();
HelloWorld.prototype = Object.extendsObject(AbstractAjaxProcessor, {
helloWorld:function() {
var user_sysid = this.getParameter('sysparm_user_name');
gs.addErrorMessage( user_sysid); ----------------------- working
var getRecord = new GlideRecord('sys_user');
getRecord.query('sys_id',user_sysid);
if(getRecord.next()){
var printvalue= getRecord.user_name;
gs.addErrorMessage(printvalue); ------------ not working
gs.log("print value "+printvalue); -------------- not working
return printvalue;
}
} ,
});
Regards,
Ajay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2019 11:10 AM
The problem is solved, there was a minor but very bad mistake, it working now
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2019 11:32 PM
Hello Suprakash,
getRecord.next();
The above line is an iterating function. You need to use an IF condition or while loop to iterate to next value.
Eg.
if(getRecord.next())
{
// add your error message
}
Thank you.
Regards,
Shubham