Hide button in IIQ workflow based on user

Which IIQ version are you inquiring about?

8.3

Hi All!

I have a workflow launched via a quicklink, which is used by different user groups in my organization.
The workflow shows a form, the form displays some value.
Now I want to add a Next button in this form to go to next step in workflow. This Next button needs to be shown to some users and hidden for others.
Is there a way to achieve this? That is add a button to form in workflow where button is visible to some users and not visible to others.

To dynamically hide or remove a button based on a user’s group, use a function within a field validation script on a form. Ensure the field is marked as dynamic=true for the script to take effect. Here’s the approach to implement this:

  1. Use context.getUserName() to retrieve the current user’s identity.
  2. Determine the user’s group based on their identity.
  3. Apply an if condition to hide or remove the button based on the group.
    public void removeButtonByLabel(Form form, String label) {
      List buttons = form.getButtons();

      for (Button button : buttons) {
        if (label.equals(button.getLabel())) {
          form.remove(button);
          break;
        }
      }
    }
1 Like

Where will I add this script? I can’t add dynamic=true in a button in a form.

Can you get me an example?

Thanks!

The logic is implemented in a field in the form like the following not on the button. I believe you might be able to achieve this without the dynamic=true. You are essentially hijacking the logic for the form in a field. Please try some trial & error.

<Field>
  <Script>
    <Source><![CDATA[
      import sailpoint.object.Form;
      import sailpoint.object.Form.Button;
      import sailpoint.object.Identity;

      Identity launcher = context.getObjectByName(Identity.class, context.getUserName());

      if (logic to check if launcher has groups) {
        removeButtonByLabel(form, "Next");
      }

      return "sample";
    ]]></Source>
  </Script>
</Field>
2 Likes

Thank you! It worked. This was a life saver.

2 Likes

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