Get Identity object with its attribute such as employee number

Which IIQ version are you inquiring about?

8.4

Hi Experts,

I would like to know if it is possible to get an Identity object using an identity attribute such as ‘employeeNumber’. In most cases, we can directly retrieve an Identity object using the identityName, as shown below:

Identity identity = context.getObject(Identity.class, identityName);

But what if we have situation that identityName is not being passed in the workflow, would like to know the alternative way to get identity object.

Hi @Bernardc,

you can use context.search(Identity.class,QueryOption); Where you build the QO with a filter on the attribute that you want, the attribute must be Searchable.

Hi @enistri_devo ,

Great idea, but not sure am I doing it correcttly?

QueryOptions qo = new QueryOptions();
qo.addFilter(Filter.eq("employeeId", enterpriseId));
Identity identity = context.getObjectById(Identity.class, qo);

No, must be:

QueryOptions qo = new QueryOptions();
qo.addFilter(Filter.eq("employeeId", enterpriseId));
Iterator itIdn = context.search(Identity.class, qo);

later you can iterate on the Iterator:

while(itIdn.hasNext()){
  Identity idn = itIdn.next();
}

In every case, if you some dubts on the funcions you can check the javadoc of IIQ:
http:///identityiq/doc/javadoc/index.html?overview-summary.html

Hi All,

Big shout out to @enistri_devo . I have gave it a try and below is my success case:

QueryOptions qo = new QueryOptions();
qo.addFilter(Filter.eq("employeeId", "1234567"));

Iterator it = context.search(Identity.class, qo);
Identity identity = null;
if (it != null && it.hasNext()) {
    identity = (Identity) it.next();
}

…as I said, @Bernardc:expressionless_face: