Business Rule Script Help plz..

Snow Angel
Tera Expert

Hello everyone,

How do I script in Business rule to achieve below requirement.

When  "Create Security Incident" button (existing UI Action) is clicked within an Incident record, the Description field contents for the Incident should be copied to the Description field within the resulting Security Incident.

 

Please help. TIA

5 REPLIES 5

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Why would this be a Business Rule requirement? Can't you just change the UI Action?

 

Please provide a bit more context to your question.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hello Mark,

How do I approach to script this in a UI Action? Can you help? TIA

Most lickely there's some code in the UI Action to create the Security Incident, or through a Script Include. So you can expand that. Instead of coding almost the same in a separate Business Rule.

 

If you need help on that, share details of your setup.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi,

 

You can modify the OOB script include named "SecurityIncidentUtils"

add:

 

 

		gr.setValue('description', currentIncident.description);

 

 

after line 440 there. However, I would not recommend that you modify the OOB UI Action or the OOB Script include.

 

Instead, create a Business rule that is defined on the 'sn_si_incident' table, runs Before with an Order value greater than 100, Runs on Insert, Condition with 'Description', 'is empty', and a 2nd condition "Initiated from", "is not empty".  Set Advanced checked and script logic as follows:

 

 

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var inc = new GlideRecord('incident');
    inc.addQuery('sys_id', current.initiated_from.toString());
    inc.query();
    if (inc.next()) {
        current.description = inc.description;
		gs.info("setSecurityIncidentDesc: Using description from " + inc.number + " for: " + current.number);
    }

})(current, previous);