In my form’s field I had written a script under allowedValuesDefinition tag.
I have moved that piece of script in a rule file and referencing it using below code.
<AllowedValuesDefinition>
<RuleRef>
<Reference class="sailpoint.object.Rule" name="Rule Selection"/>
</RuleRef>
</AllowedValuesDefinition>
Also I have added a boolean in the rule file which I want to mention true or false in the AllowedValuesDefenition tag, so based on the condition one additional filter will be applied else not.
For this I have mentioned an if condition in my rule file.
I want to change that boolean to true or false at form level.
How can I do this.
I am adding the rule file below.
<Source>
import sailpoint.object.Identity;
import sailpoint.object.Filter;
import sailpoint.object.QueryOptions;
import sailpoint.tools.Util;
import java.util.ArrayList;
import java.util.List;
import java.util.Iterator;
boolean filterByManager;
List selectedNPIdentityList = new ArrayList();
QueryOptions queryOptions = new QueryOptions();
// Common filters for both cases
queryOptions.addFilter(Filter.eq("cwtype", "NPIdentity"));
queryOptions.addFilter(Filter.eq("workertype", "NPIdentity"));
// Add manager filter only for self selection
if(filterByManager) {
Identity launcher = context.getObjectByName(Identity.class, context.getUserName());
queryOptions.addFilter(Filter.eq("manager.name", launcher.getName()));
}
Iterator it = context.search(Identity.class, queryOptions);
while (it.hasNext()) {
Identity identity = (Identity) it.next();
String firstName = identity.getAttribute("firstname");
String lastName = identity.getAttribute("lastname");
String ssoId = identity.getAttribute("workerid");
if (Util.isNotNullOrEmpty(firstName) && Util.isNotNullOrEmpty(lastName) && Util.isNotNullOrEmpty(ssoId)) {
String displayName = String.format("%s %s (%s)", firstName, lastName, ssoId);
selectedNPIdentityList.add(displayName);
}
}
return selectedNPIdentityList;
</Source>