Help in Scripting if(gr.next()) is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-26-2019 11:44 PM
After madrid upgrade this script is not working in prod, the same is working in kingston.
Below code is displaying description of incident on approval request in portal but description is not getting visible after madrid upgrade only for incident.
kindly guide if anything wrong in it.
if (record.source_table == 'incident') {
gs.log("Madrid Changes hello");
var inc = new GlideRecord('incident');
inc.addQuery('sys_id', record.sysapproval.sys_id.toString());
gs.log("Madrid Changes variable" + record.sysapproval.sys_id.toString());
inc.query();
if (inc.next())
{
gs.log("Madrid changes dsc" + inc.description.toString());
ticket.description = inc.description.toString();
ticket.comment_approval = 'true';
}
}
Logs are not coming inside if (inc.next()) and if I remove the IF condition value is not coming in inc.description.toString();
In sort inc.description.toString(); is not working as well.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-27-2019 01:27 AM
so you have any issue with addQuery().
do one thing try to run the above code by hard-cording the sysid and see if it it's working or not.
run the below code in background script.
var inc = new GlideRecord('incident');
inc.addQuery('sys_id','5f1f9d2fdb217b40c4759ef7db96196f');
inc.query();
gs.log('Row Count is'+ inc.getRowCount());
if (inc.next())
{
gs.log(inc.number);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-27-2019 01:38 AM
Yes got result as
*** Script: Row Count is1
*** Script: INC1387915

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-27-2019 01:46 AM
if(record.source_table == 'incident') {
gs.log("Madrid Changes hello");
var inc = new GlideRecord('incident');
inc.get(record.sysapproval);
gs.log('Number is '+ inc.number);
ticket.description = inc.description;
ticket.comment_approval = 'true';
}
try now and see if it works or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-27-2019 01:56 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-27-2019 02:02 AM
try to hard-code the sysid in the script and see if it's giving the result on portal or not.
if it works by hard-cording the sysid then try again with below script.
if(record.source_table == 'incident') {
var op = record.sysapproval.sys_id;
gs.log("Madrid hello" + op);
var inc = new GlideRecord('incident');
inc.get(op);
gs.log('Number is '+ inc.number);
ticket.description = inc.description;
ticket.comment_approval = 'true';
}