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-18-2023 04:22 AM
@Community Alums
why not to use the OOB Context menu?
It does the same thing
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:32 AM
@Community Alums
you are not querying properly
update as this
var gr = new GlideRecord('incident');
gr.addEncodedQuery('u_requestISNOTEMPTY');
gr.query();
if (gr.next()) {
var incNum = current.sys_id;
var ReqsysId = current.u_request; //here u_request field is present on Incident table, which stored Request No.
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();
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
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 07:33 AM
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,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 07:34 AM
@Community Alums
u_request holds sysId or REQ number?
if number then use this
req.addQuery('number', ReqsysId);
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 11:08 PM
Tried this, but still not working.