Populating Identities which are under me

Hi,
In a field I need to populate Identities who are assigned to me.
In other words those identities who’s manager attribute is populated with my credentials.
The format should be [firstname + lastname + (ID)]
I am usign below code:

<Field displayName="Select NPIdentityID" dynamic="true" name="selfNPIdentity" postBack="true" type="string">
      <AllowedValuesDefinition>
        <Script>
          <Source>
            import sailpoint.object.Identity;
            import sailpoint.object.Filter;
            import sailpoint.object.QueryOptions;
            import java.util.ArrayList;
            import java.util.List;

            List allowedValues = new ArrayList();
            Identity currentUser = context.getObjectByName(Identity.class, context.getUserName());
            if (currentUser != null) {
            QueryOptions qo = new QueryOptions();
            qo.addFilter(Filter.eq("manager.id", currentUser.getId()));
            qo.addFilter(Filter.eq("workertype", "NPIdentity"));
            Iterator it = context.search(Identity.class, qo);
            while (it.hasNext()) {
            Identity identity = it.next();
            String firstName = identity.getFirstname();
            String lastName = identity.getLastname();
            String ssoId = identity.getAttribute("workerid");
            allowedValues.add(String.format("%s %s (%s)", firstName, lastName, ssoId));
            }
            }
            return allowedValues;
          </Source>
        </Script>
      </AllowedValuesDefinition>

But after selecting the identity receiving below error

sailpoint.tools.GeneralException: Typed variable declaration : Error in method invocation: Method getName() not found in class’java.lang.String’ : at Line: 14

Hi @pctripathi Seems like you are getting error from other fields. Since postback is enabled on this field, other field logics (which are dynamic) will be evaluated as soon as you choose the value in current field.

Hey @pctripathi

let’s try out to add cast for class types:

Identity identity = (Identity) it.next();
String firstName = identity.getFirstname();
String lastName = identity.getLastname();
String ssoId = identity.getStringAttribute("workerid");
allowedValues.add(String.format("%s %s (%s)", firstName, lastName, ssoId));