BR to autopopulate RITM value on incident form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 08:17 PM
I have created a custom field called REQUESTED ITEM(u_requested_item) in related records.
Now I have to autopopulate this field when a request is created from the incident.
I have used a Before BR:
Before - Insert&update
condition: current.sys_class_name == 'incident' && current.u_requested_item.nil()
Script:
(function executeRule(current, previous /*null when async*/) {
if (current.sys_class_name == 'incident' && current.request_item.nil()) {
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', current.sys_id);
ritm.query();
if (ritm.next()) {
current.request_item = ritm.sys_id;
}
}
})(current, previous);
For some reason its not populating.
Iam using UI action from incident to create a request.
Can anyone help on this?
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 10:59 PM - edited 11-07-2023 11:03 PM
Create business rule on RITM,
Before insert/update
Condition - Request is not empty and request changes
(function executeRule(current, previous /*null when async*/) {
var req= new GlideRecord('sc_request');
if(req.get(current.request)){
if (req.sys_class_name == 'incident' && req.u_requested_item.nil()) {
req.u_requested_item = current.sys_id;
req.update();
}
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 09:57 PM - edited 11-07-2023 09:57 PM
If the incident record in question is create via record producer, you will not have a corresponding RITM number. Please share details on how the incident record was created.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 11:29 PM
They create it manually too..Level 1 team creates it manually..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 11:20 PM
if you create a request from incident, then in the REQ the parent field gets populated with INC
Why to have custom field on INC?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 11:24 PM
The exact requirement is as follows,
Create Request Item field in Related Records in Incident Form.
Field should populate with RITM# once Request is created from Incident.
This will ensure the handshake is done between Incident & RITM.