Rule where 'context.countObjects' is used - to use only IDNRuleUtil attrSearchCountAccounts instead

Hi,

Using for a while small cloud executed Rules like one ‘listToCsv’ below that helps us working with Google multi-valued attributes (Phones, Groups), we were told by IdentityNow Rule Validator report that we must rewrite all the Rules where ‘context.countObjects’ is used to use only IDNRuleUtil attrSearchCountAccounts instead.

Looking on magnificent samples of Attribute Generator Rule from @hari_patel , @ross_shwarts and @Rich_Miller, @piyush_khandelwal, @pedrolit0, l’d like to ask some help here from a Development community for samples of rewriting the code below using IDNRuleUtil attrSearchCountAccounts., particular code line is … Iterator links = context.search(Link.class, ops, “attributes”);

1, 2

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import sailpoint.api.SailPointContext;
import sailpoint.object.Attributes;
import sailpoint.object.Filter;
import sailpoint.object.Identity;
import sailpoint.object.Link;
import sailpoint.object.QueryOptions;
import sailpoint.tools.Util;

// basic sanity checks
if ((cloudSourceName == null) || (attributeName == null) || (identity == null))
	return null;
	
ArrayList allowedDataFeeds = new ArrayList();
QueryOptions ops = new QueryOptions();
ops.addFilter(Filter.eq("identity.name", identity.getName()));
ops.addFilter(Filter.eq("application.cloudDisplayName", cloudSourceName));
ops.setOrderBy("created");
ops.setOrderAscending(false);

Iterator links = context.search(Link.class, ops, "attributes");   
while (links != null && links.hasNext()) {
	Object[] row = (Object[]) links.next();
	Attributes attributes = (Attributes) row[0];
	if (attributes != null ) {
		vals = (ArrayList) attributes.getList(attributeName);
		return Util.listToCsv(vals);
	}
}
return null;

===================

Sample of Transform we are using with that Rule is like that:

{
“attributes”: {
“attributeName”: “Groups”,
“cloudSourceName”: “GWS source (Google)”,
“name”: “ListToCsv”
},
“type”: “rule”
}