Share all details related to your problem, including any error messages you may have received.
I need to create an Assignment Rule for populating a Business Role.
The criteria for the Rule is - all Identities whos location is not Canada but they are the Manager to an Identity whos location is in Canada.
I don’t know how/where to get started with this and was hoping someone had an example Assignment Rule that I could try to work off of to get this working.
I have been searching and reading the “Rules” doc, but didn’t find anything that seemed like this type of rule.
just my though … it may better count objects instead of search and return true when count (countObjects(java.lang.Class cls, QueryOptions options)) is greater than 0 … thinking in terms of performance
Thanks so much for the replies and help, WAY over my level of understanding!
I tried the code and get -
BeanShell script error: bsh.ParseException: Parse error at line 16, column 19. Encountered: qo BSF info: NonCanadianMgr at line: 0 column: columnNo
I over simplified my question, I don’t actually have a single ‘Canada’ location I can search. I have to search for multiple values, I was hoping it would be something like this (excuse my ignorance) -
I started with just ‘Saskatoon’ in hopes I could expand it to all three locations at some point -
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<Rule created="1703184577302" id="0aab09888bec1fc4818c8db6331622e0" language="beanshell" modified="1703184879051" name="NonCanadianMgr" type="IdentitySelector">
<Description>This rule is used to select an Identity that is related to the given Identity</Description>
<Signature returnType="boolean">
<Inputs>
<Argument name="log" type="org.apache.commons.logging.Log">
<Description>
The log object associated with the SailPointContext.
</Description>
</Argument>
<Argument name="context" type="sailpoint.api.SailPointContext">
<Description>
A sailpoint.api.SailPointContext object that can be used to query the database if necessary.
</Description>
</Argument>
<Argument name="identity" type="Identity">
<Description>
The identity.
</Description>
</Argument>
<Argument name="roleName" type="String">
<Description>
The name of the sailpoint.object.Bundle (role) that is being selected for the Identity.
If roles are not applicable to this Identity selection, this value will be void.
</Description>
</Argument>
</Inputs>
<Returns>
<Argument name="success">
<Description>
True if the selection was successful; false otherwise.
</Description>
</Argument>
</Returns>
</Signature>
<Source>import sailpoint.object.QueryOptions;
import sailpoint.object.Filter;
String identityId = identity.getId();
String location = "Saskatoon";
String locationAttributeName = "location";
if(!location.equals(identity.getAttribute(locationAttributeName)) {
QueryOptions qo = new QueryOptions();
Filter f1 = Filter.eq("manager.id",identityId);
Filter f2 = Filter.eq("location",location);
qo.add(Filter.and(f1,f2));
Iterator it = context.search(Identity.class,qo);
if(it.hasNext()) {
return true;
}
}
return false;</Source>
</Rule>
the condition if(!location.equals(identity.getAttribute(locationAttributeName)) doesn’t have closing bracket you need to use if(!location.equals(identity.getAttribute(locationAttributeName)))
Remember this rule needs to be as efficient as possible as it will be executed for every single identity during identity refresh so if you put to much if’s it may impact performance.