Script is working in background script but not working in Business Rule

Vengeful
Mega Sage

What seems to be the reason why script is working in background script but  not working in Business Rule?

1 ACCEPTED SOLUTION

@Vengeful 

how many records you want to insert sn_grc_issue? 1 or some other value?

try this

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

	var entity = new GlideRecord('sn_grc_profile');
	entity.query();
	while (entity.next()) {
		var issue = new GlideRecord('sn_grc_issue');
		issue.initialize();
		issue.classification = 3;
		issue.short_description = entity.name + ' has a control test failure';
		issue.insert();
	}

})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

13 REPLIES 13

@Vengeful 

how many records you want to insert sn_grc_issue? 1 or some other value?

try this

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

	var entity = new GlideRecord('sn_grc_profile');
	entity.query();
	while (entity.next()) {
		var issue = new GlideRecord('sn_grc_issue');
		issue.initialize();
		issue.classification = 3;
		issue.short_description = entity.name + ' has a control test failure';
		issue.insert();
	}

})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hi @Ankur Bawiskar 
Actually the requirement here is that when a control test issue is closed and the Control effectiveness is Ineffective it will create an Issue.

Merza_0-1699511694698.png

 

And when the issue is created, the Classification should be auto-populated to 'Audit' which is the value is 3.

Merza_1-1699511867449.png

 

Merza_3-1699511918936.png

 

@Vengeful 

I hope your BR is having proper conditions i.e State is Closed AND Control Effectiveness is Ineffective

you are querying entire sn_grc_profile table without any filter but why?

which GRC Profile you want to pick? add that query

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

@Ankur Bawiskar Here's the table and filter condition in BR

Merza_0-1699513767402.png

 

@Vengeful 

so BR is on sn_audit_control_test and based on BR condition you want to create issue for the sn_audit_engagement

I am not very sure on the table hierarchy for GRC, but what I could say is your requirement is simple to achieve using script

If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.

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