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-08-2023 12:17 AM
So can you share the code used in UI Action to understand how the linking is happening between Incident and Request.
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 12:21 AM
current.update();
var url;
var activeCatalogsCount = sn_sc.Catalog.getCatalogCount();
if (activeCatalogsCount === 1) {
url = 'sp?id=sc_category&catalog_id=e0d08b13c3330100c8b837659bba8fb4';
}
else {
url = 'sp?id=sc_category&catalog_id=e0d08b13c3330100c8b837659bba8fb4';
}
action.setRedirectURL(url);
It redirects to the SP page for raising request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 12:35 AM
So it is not creating Request Automatically but as to submit request manually from Portal.
So how to figure out that it happened through Incident? I am looking for that link that how system know that this Request was created through Incident? Is Parent field on REQ getting populated with Incident number?
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 01:52 AM
You're right..Looks like we dn've a common link at all... what would you suggest in that case?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 02:09 AM
Hi @Swetham
What I can suggest it that when you redirect it to Portal with Catalog Item, you can have a hidden variable which can auto populate Incident Number or Incident Reference. Once Request is Submitted, you can map Parent field of REQ or RITM with that Incident record from hidden variable.
Then, you can create After BR on REQ or RITM where you have mapped Parent as Incident and there you can write code to map that number with your Custom Field on Incident record.
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023