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.

How to get the list of records that got removed from list field.

test1231998
Tera Contributor

i have a list field called managers referencing to sys_user table.

So whenever the user gets removed from the manager field, I need to set another field as false.

But for this how can i get the list of all users that is removed from the manager list field.

How to write a Br to get the list of all users that is removed from the list field manager.

1 REPLY 1

Brad Bowman
Kilo Patron
Kilo Patron

In a before Update Business Rule, you can use the previous object.  Combined with the ArrayUtil methods, you can easily get a list of records removed from the List field like this:

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

	prevArr = previous.u_managers.split(',');
	curArr = current.u_managers.split(',');
	var arrayUtil = new global.ArrayUtil();
	var delArr = arrayUtil.diff(prevArr, curArr);
	gs.addInfoMessage('del=' + delArr)
		
})(current, previous);