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 08:22 PM - edited 11-07-2023 08:24 PM
Hi @Swetham ,
I think you have to replace current.request_item.nil() with current.u_requested_item.nil()
Please let me know if it's correct or not.
Please mark the answer correct/helpful based on Impact.
Regards, Anup
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 10:38 PM
I have rectified that and it still doesn't work..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 10:45 PM
Hellow @Swetham ,
You are trying to fetch it and trigger condition is before insert - request. So how it will get ritm with the request which is still not created. See below line from your code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 10:49 PM
I see it.. You have any suggestions?