Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

BR to autopopulate RITM value on incident form

Swetham
Tera Contributor

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!

 

20 REPLIES 20

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);

 

 

Narendranath R1
Tera Contributor

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.

They create it manually too..Level 1 team creates it manually..

Ankur Bawiskar
Tera Patron
Tera Patron

@Swetham 

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?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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.