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 02:12 AM
Hi @Community Alums
What is the type of u_request field and is it populating related record?
Regards
Ankit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 03:09 AM
Hello @Ankit Rawat ,
Thanks for your response,
u_request is the request field present on Incident form, when incident is converted to Request at that time the Request no. will auto populate in this field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 02:40 AM
@Community Alums
parent field on REQ should populate with Incident when you are using OOB "Convert to Request" context menu.
are you using some other custom button on incident form?
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 03:40 AM
Hi @Ankur Bawiskar ,
Thanks for Your Response,
I have used "Convert To a Request" Form Button, not a OOB 'Convert to Request' context menu.
Please find my code Of UI Action Attached below, and please let me know how can Auto populate Inc no. on parent field of Request form.
var dialog = new GlideDialogWindow("catalog_item_list_v2", false, 700, 200);
dialog.setTitle("");
dialog.removeCloseDecoration();
dialog.setPreference("number", g_form.getValue("number"));
dialog.setPreference("short_description", g_form.getValue("short_description"));
dialog.setPreference("state", g_form.getValue("state"));
dialog.setPreference("parent", g_form.getUniqueValue());
//dialog.setPreference("parent", g_form.getValue("parent"));
dialog.setWidth(700);
dialog.render()
Then for Auto populating Inc no. on Request form i have written one Business rule on Inc table
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(ReqsysId,'sys_id');
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();
}
In above Business Rule, all the logs are working fine, i'm getting the proper sysids for INC and Req, but in the last log( gs.log('AAAAAAAA' + req.sys_id);),
here, i should get the request sys id which is recently converted from the Incident but in that log I'm getting one old Request , every time whenever i test. please find the logs
Could you please help me to get the proper solution.
Thanks,
Priya