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:21 AM
Because we are displaying incident description on portal for approver to approve incident

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-27-2019 02:16 AM
Yes, but record.sysapproval.sys_id.toString() returning incident record or approver record?
Can you print the value of this record.sysapproval.sys_id.toString() and then go to incident.list and filter by sys_id and put this value and check if you are getting the record or not.
Mark the comment as a correct answer and also helpful once worked.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-28-2019 05:09 AM
Hi Priya,
Is the issue resolved? If not, kindly follow the steps once that i have mentioned above.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-27-2019 12:21 AM
the best way to check the rowCount() of your second glide record , might be possible the addQuery() filter is not working. .
Updated script with logs. try to run and let me know the log details.
if(record.source_table == 'incident') {
gs.log("Madrid Changes hello");
var inc = new GlideRecord('incident');
inc.addQuery('sys_id', record.sysapproval);
gs.log("Madrid Changes variable" + record.sysapproval);
inc.query();
gs.log('Row Count is'+ inc.getRowCount());
if (inc.next())
{
gs.log("Madrid changes dsc" + inc.description.toString());
ticket.description = inc.description;
ticket.comment_approval = 'true';
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-27-2019 01:19 AM
Result -
Madrid Changes variable5f1f9d2fdb217b40c4759ef7db96196f
Row Count is0