Business Rule - Determine what changed in a list field

Dazler
Mega Sage

Hi,

 

I have a custom field (List) on the Incident table, this list field references to the Change Request table using Related List.  Since related list cannot be added to CAB Workbench, the work around that I have come up with is to create a separate field on the Change record and copy all the related list records to that field (so they can display on the CAB Workbench).

 

One thing I did was create an After Business Rule on the Incident table that is used to update a field on Change.  I got it to work if a new record was added to the list, but I realized that if a user in the Incident record removes one of the records from the custom field list, that will not update the change record because it doesn't know what record was removed.

 

So what I am looking for is a way in the business rule to know what was change, more so what record was removed.

 

Is there a way that I can do detection in my business rule?

 

Any help would be appreciated.

1 ACCEPTED SOLUTION

Bert_c1
Kilo Patron

I see a reply here to the same question:

 

https://www.servicenow.com/community/developer-forum/how-to-get-the-list-of-records-that-got-removed...

 

with script logic to see the difference in the field values.

View solution in original post

4 REPLIES 4

Tony Chatfield1
Kilo Patron

Hi, your configuration\requirement is not very clear but I suspect you might also need to look at an on delete BR, when a related list entry is deleted, update the change_request.field with a corrected value.

Bert_c1
Kilo Patron

Please see:

 

https://docs.servicenow.com/bundle/tokyo-application-development/page/script/business-rules/concept/...

 

And the business rule template:

 

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

	// Add your code here

})(current, previous);

You have access to 'current' and 'previous' versions of the record.  Compare current.[field_name] to previous.[field_name] to detect a change, where [field_name] is your field.  Parse that value list to see differences.

Bert_c1
Kilo Patron

I see a reply here to the same question:

 

https://www.servicenow.com/community/developer-forum/how-to-get-the-list-of-records-that-got-removed...

 

with script logic to see the difference in the field values.

Thank you so much!!!  This helped greatly.