now i need to seach an additional attribute that is multivalued for that same uniqueness and when i try to it the same way it fails.
i tried it this way :
QueryOptions qo3 = new QueryOptions();qo3.addFilter(Filter.contains(“oidNplexInternetMailAddress”, mailprefix)); //oidNplexInternetMailAddress is multivalued
List<Identity> alias = context.getObjects(Identity.class, qo3);
and then adding it to my if condition but the qo3 is failing
well when i select Multi-Valued in the Identity Mappings where i created the attribute, i cannot select the Searchable Checkbox Anymore, as for the error, nothing in the interface except i can see it’s not doing the job when i add this code…
Multi-valued attributes are searchable by default, but they are stored separately in the database so you have to join your query. Just another tip, don’t insert new multivalued attributes via debug, it won’t get added properly and you won’t get results.
Hope this helps:
import sailpoint.api.*;
import sailpoint.object.*;
import sailpoint.search.ExternalAttributeFilterBuilder;
String mailprefix = "";
Filter filter = ExternalAttributeFilterBuilder.buildOrFilter("IdentityExternalAttribute", "id", "oidNplexInternetMailAddress", Util.csvToList(mailprefix), "EQ");
QueryOptions qo = new QueryOptions();
qo.add(filter);
qo.setResultLimit(1); // You only need to find one to know it's not unique
List identities = context.getObjects(Identity.class, qo);
return identities.isEmpty(); // true is unique
You have the option to use buildAndFilter (looks for all values in the list) or buildOrFilter (looks for any values in the list). There’s also constants in case you would rather write it like this: