I have question on Incident Number is not populating on Request form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 01:51 AM
Hi There,
I have one issue, when Incident is converted to Request at that time Incident number should auto populate on request form parent field, for this I have written one After (Insert/Update) Business Rule On Incident Table,
And in Script logs also, I'm getting the proper Incident and Request Sysid's but on the Request form, parent field is not populating with the Incident number.
please find the below code
var gr = new GlideRecord('incident');
gr.addEncodedQuery('u_requestISNOTEMPTY');
gr.query();
if (gr.next()) {
var incNum = current.sys_id;
var ReqsysId = current.u_request;
gs.log('The Number of Incident is:' + incNum + " " + ReqsysId);
}
var req = new GlideRecord('sc_request');
req.addQuery('sys_id', ReqsysId);
req.query();
if (req.next()) {
gs.log('Checking');
req.parent = incNum;
gs.log('field check' + ' ' + req.parent)
gs.log('AAAAAAAA' + req.sys_id);
req.update();
}
Can some one please help me to populate Incident Number on parent field,
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 12:02 AM
@Community Alums
any update on this?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 04:48 AM
Hi Priya,,
To fix this, you can modify your code as follows:
var gr = new GlideRecord('incident');
gr.addEncodedQuery('u_requestISNOTEMPTY');
gr.query();
if (gr.next()) {
var incNum = gr.sys_id; // get the sys_id value of the incident record
var ReqsysId = current.u_request;
gs.log('The Number of Incident is:' + incNum + " " + ReqsysId);
}
var req = new GlideRecord('sc_request');
req.addQuery('sys_id', ReqsysId);
req.query();
if (req.next()) {
gs.log('Checking');
req.parent = incNum; // set the parent field value to the incident sys_id
gs.log('field check' + ' ' + req.parent)
gs.log('AAAAAAAA' + req.sys_id);
req.update();
}
Thanks,
Rahul Kumar
Thanks,
Rahul Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 07:33 AM
Hi @Rahul Kumar17 ,
Thanks for your response
I have tried the above but which is also not working.
req.addQuery('sys_id',ReqsysId);
This Query is not running,
All the logs after this line are not triggering.
Could you please help me where i need to change.
Thanks,