IIQ Form - Add more button

Which IIQ version are you inquiring about?

8.3

Share all details about your problem, including any error messages you may have received.

I created a form and tried to add a “Save and Add Another” button using the following section:

<Section label="Saved Role/Entitlement Entries" name="savedSection">
  <Field displayName="Save and Add Another" name="savedSelections" type="button">
    <Attributes>
      <Map>
        <entry key="buttonLabel" value="Save and Add Another"/>
        <entry key="onClick">
          <value>
            <Script>
              <Source>
              </Source>
            </Script>
          </value>
        </entry>
      </Map>
    </Attributes>
  </Field>
</Section>

However, instead of rendering a button, it shows a text label and a text input field.

I followed the reference in this article:
https://developer.sailpoint.com/discuss/t/add-more-button-in-form/126087/3

Initially, I received an error on the line:

<value>Click Me</value>

To resolve it, I replaced it with:

<entry key="buttonLabel" value="Click Me"/>

The intended logic of this button is to store the entered data temporarily so that the user can clear the fields, input new values, and ultimately submit all entries together as a bulk request.

Below is the Java logic I plan to use for storing and resetting values (though I first tested without logic to isolate the UI issue):

import java.util.*;

if (form.getField("savedSelections").getValue() == null){
    List input = new ArrayList();
    form.getField("savedSelections").setValue(input);
}

List saved = (List) identityModel.get("savedSelections");
String type = (String) form.getField("selectAccess").getValue();
Map entry = new HashMap();
entry.put("entryType", type);
entry.put("operation", form.getField("selectop").getValue());

if ("Roles".equals(type)) {
    Object r = form.getField("roles").getValue();
    if (r instanceof java.util.List) {
        entry.put("roles", String.join(",", (List) r));
    } else {
        entry.put("roles", r != null ? r.toString() : "");
    }
    entry.put("appName", "");
    entry.put("ents", "");
    Object c = form.getField("comments").getValue();
    entry.put("comments", c != null ? c.toString() : "");
} else {
    Object a = form.getField("appName").getValue();
    entry.put("appName", a != null ? a.toString() : "");
    Object e = form.getField("entitlements").getValue();
    if (e instanceof java.util.List) {
        entry.put("ents", String.join(",", (List) e));
    } else {
        entry.put("ents", e != null ? e.toString() : "");
    }
    entry.put("roles", "");
    Object c2 = form.getField("comments").getValue();
    entry.put("comments", c2 != null ? c2.toString() : "");
}

saved.add(entry);
identityModel.put("savedSelections", saved);

// Reset input fields
form.getField("roles").setValue(null);
form.getField("appName").setValue(null);
form.getField("entitlements").setValue(null);
form.getField("comments").setValue(null);

At this stage, the main issue is that the field definition is not producing a button in the form.

Hi @AlaaKhaled

If you want add a Button in Form, you don’t need to add Form **Field **
You can add a tag for Button something like this.

<Button action="next" label="Save and Add Another"/>

And you can add another Form in workflow after this form is submitted by adding a transition

Hi @tharshith
thank you for your reply.
i need more details on how to do this. i have a step in the workflow called “Launch Workflow for Bulk” which contains all the logic. how can i add a condition so that it only moves to this step if the button clicked is “submit” and not “save and add another”?
kindly also be informed that i have two forms:

  • the first form is to collect the users on whom the bulk request will be applied.

  • the second form is for the entitlements and roles.

i need the one to be repeated again to be the second form, not the first one.

so can i add a transition so that if the “save and add another” button is clicked, it reloads only the second form again?

Hi @AlaaKhaled

To achieve this you need to have 2 different steps in workflow, such that step1 will launch form1 and step2 will launch form2.

You need to add a transition in Step1 as below

<Transition to="Step 2" when="approved">

This will redirect you to 2nd form as soon as you 1st form.
Now in Step 2, you’ll have Form 2. Here also you have to add 2 buttons

<Button action="next" label="Submit"/>
<Button action="refresh" label="Save and Add Another"/>
<Button action="back" label="Cancel"/>

In your Step2, you have to create a map to save previously existing form data, add that map to a list (this should be your workflow variable). Type refresh will automatically erase details entered in Form and gives you new Form in UI. And transitions of your step should be something like this -

<Transition to="Next Steps" when="approved">
<Transition to="End" when="!approved">

Hope this helps you.

Hi @tharshith

Many thanks for your help.
I got your point. I have one final question:
In Step 2, there is already an <Approval> tag that renders the form. I am not able to inject a <Script> tag to store the data in a list. I checked different nested validationScript options, but all of them are executed after approval, not after refresh.
Is there any workaround for this?

Thanks in advance.

Hi @tharshith
Any update please?

Hi @AlaaKhaled

You can use a dummy form field (read-only, not reviewrequired) to save all the form inputs in a map. Add that map to workflow variable which should be a List. So every time you enter details in form, in the last field you save all details and return to workflow variable.

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