Pre-populate Identity Field (Change Manager) in Form

I’m trying to build a custom LCM provisioning form in SailPoint IIQ 8.3 to allow users to change their manager. I want the current manager to be pre-selected in the “Change Manager” dropdown when the form loads.

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Form PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<Form name="Test_ChangeManager_Form" type="Workflow">
  <Section columns="1" label="Change Manager" name="ChangeManagerSection">
  
    <!-- Hidden field to debug 'name' -->
    <Field name="name" type="string">
      <Attributes>
        <Map>
          <entry key="visible" value="false"/>
        </Map>
      </Attributes>
    </Field>

    <!-- Change Manager field with script to pre-fill -->
    <Field displayName="Change Manager" name="NewManager" type="sailpoint.object.Identity">
      <Attributes>
        <Map>
          <entry key="suggest" value="true"/>
          <entry key="displayAttribute" value="displayName"/>
          <entry key="objectType" value="sailpoint.object.Identity"/>
        </Map>
      </Attributes>
      <Script>
        <Source>
          import sailpoint.object.Identity;
          import org.apache.commons.logging.Log;
          import org.apache.commons.logging.LogFactory;

          Log log = LogFactory.getLog("FORM_ChangeManager_Debug");

          log.error("==== DEBUG: name = " + name);

          try {
            if (name != null) {
              Identity user = context.getObject(Identity.class, name);
              if (user != null) {
                Identity manager = user.getManager();
                log.error("==== DEBUG: manager = " + (manager != null ? manager.getDisplayName() : "null"));
                return manager;
              }
            }
          } catch (Exception e) {
            log.error("==== ERROR getting manager: ", e);
          }

          return null;
        </Source>
      </Script>
    </Field>

  </Section>
  <Button action="back" label="Cancel"/>
  <Button action="next" label="Submit"/>
</Form>

I confirmed that:

  • The name variable (Identity name) is available in the form context.
  • The user has a valid manager with a displayName.
  • Logging shows the script returns the manager object correctly.

Still, the dropdown is not showing the pre-filled value.

Hello @Viraj

After reviewing your code looks like field return value is not properly set. Instead of returning manager try to use return manager.getDisplayName() as field is expecting string value as return. Let me know if it works for you.

Hi @Viraj , Instead of returning the identity object return the username of the manager . below is quick code snap -

return manager.getName();

Hi Viraj
I can see that Even though your script returns an Identity object, the dropdown needs its name, not the full object.

  import sailpoint.object.Identity;
      import org.apache.commons.logging.Log;
      import org.apache.commons.logging.LogFactory;

      Log log = LogFactory.getLog("FORM_ChangeManager_Debug");

      log.error("==== DEBUG: name = " + name);

      try {
        if (name != null) {
          Identity user = context.getObject(Identity.class, name);
          if (user != null) {
            Identity manager = user.getManager();
            if (manager != null) {
              log.error("==== DEBUG: manager name = " + manager.getName());
              return manager.getName();  // here we are  returning  the Identity name can use return manager.getDisplayName() as well
            }
          }
        }
      } catch (Exception e) {
        log.error("==== ERROR getting manager: ", e);
      }

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.