Workflow Form

This example XML creates a custom form that displays the Identity's name and asks the user to select a region to which the Identity should be assigned. It demonstrates use of an AllowedValuesDefinition and a ValidationScript as well as Sections of all three types, text, datatable, and default. This form is embedded in the Workflow XML, as it would be if the form were created through the Business Process Editor Add Form option. The form could alternatively be created as a standalone form object and referenced as an argument to the approval, as described in Workflow Forms.

Copy
<Step name="Need Region" posX="359" posY="182">
  <Approval name="Need Region" owner="ref:launcher" return="region" 
          send="identityName">
    <Arg name="workItemDescription" 
           value="string:Fill in Region for $(identityName)"/>
    <Form>
     <Attributes>
        <Map>
          <entry key="pageTitle" value="Get Region"/>
          <entry key="title" value="Need Region for Identity"/>
        </Map>
     </Attributes>
     <Button action="back" label="Abort"/>
     <Button action="next" label="Submit"/>
     <Button action="cancel" label="Return Item to Inbox"/>
     
     <Section name='userInstructions' type='text'>
        <Field value="Employees must be assigned to a region.  Please provide the correct region for this employee."
/>
     </Section>

     <Section type="datatable">
       <Field displayName="Employee Name" name="identityName"/>
     </Section>
     
     <Section name="Edit These Fields">
        <Field displayName="Region Value" name="region" required="true"  
          type="String">
         <AllowedValuesDefinition>
           <Script>
             <Source>
                  import java.util.ArrayList;
            import sailpoint.api.*;
            import sailpoint.object.*;

            List regions = new ArrayList();
            QueryOptions qo = new QueryOptions();

            qo.setDistinct(true);
            qo.addOrdering("region", true);

            List props = new ArrayList();
            props.add("region");

            Iterator result = context.search(Identity.class, qo, props);
            while (result.hasNext()) {
              Object [] record = result.next();
            String region= (String) record[0];
            regions.add(region);
            }
            return regions;
             </Source>
           </Script>
         </AllowedValuesDefinition>
         <ValidationScript>
             <Source>
            // validation variable comes in as "value"
              import sailpoint.tools.Message;
               List messages = new ArrayList();
               if(value.length() &lt; 6) {
                  Message msg = new Message();
                  msg.setKey("New region must be at least 6 characters.");
                  messages.add(msg);
               }
               return messages;
              
             </Source>
         </ValidationScript>
      </Field>
    </Section>
  </Form>
 </Approval>
</Step>