Inputting comments before hitting the Rejected Button

I am trying to make a form to where you have to input comments before you hit the rejected button in the form.

      </Attributes>
    </Field>
    <Field displayName="Comments" name="comments" required="true" type="string"/>
  </Section>
  <Button action="back" label="Rejected"/>
  <Button action="next" label="Approved"/>
</Form>

Is there a validation script that can make this happen? It would be good if both buttons shown in the xml format above had this.

No, validations only run on “next”.

Is this part of a workflow? If so, you can actually have as many different “next” buttons as you want, and distinguish between them with parameter and (optionally) value attributes on your Button.

<Button action="next" parameter="nextAction" value="reject" label="Rejected"/>

When that Button is pressed, IIQ will behave like there’s a field called (in this case) nextAction on your form with a value of (in this case) “reject”. It can be returned to your workflow like any other form field value.

Your workflow can then distinguish between the buttons pressed.

Another option would be to write your workflow such that an empty “comments” field just loops back to another Form re-prompting the user for a rejection comment. The user would get the hint quickly.

1 Like

Hi Devin,

I am trying to have it function where if the user tries to click on the Reject button and did not put any comments in, then he cannot reject the form until comments are made.

Also, this is a form used in a workflow. I just want the user ti have to put in a comment no matter what once the form is visible in front of them.

Right, what I’m saying is that the values “next” and “back” (or approve / reject) are basically arbitrary for forms. There’s no default post-submit behavior, other than setting approved = true for “next” buttons, so you can do whatever you want.

Specifically, you can have two “next” buttons and call one “approve” and the other “reject”, and distinguish them using the parameter method I mentioned above. The user doesn’t have to know that both buttons are actually “action=next” buttons, because all they’ll see is the label.

Either of the options I mentioned above will work for your situation.

What if i just want to put a validation script in place so the buttons will not function until a comment is typed in. See the field I talking about below:

<Field displayName="Comments" name="comments" required="true" type="string"/>

What would the if statement be?

Hi @derrickthomasvdot

As @drosenbauer mentioned you can have Validation Script if you change Rejected button action to next.

You can add the below Validation Script for Comments and have the Rejected button action as next.

<ValidationScript>
  <Source>
  import sailpoint.object.Form.Button;
  
  Button button = form.getClickedButton();
  if (button != null) {
    if (button.getAction() != null && button.getLabel() != null && button.getAction().equalsIgnoreCase("next")
        && button.getLabel().equalsIgnoreCase("Rejected")){
        if (value == null || value.isEmpty() || value.equals("") || value.length() <= 0) {
                  return "Please enter comments for rejection.";
        }
    }
  }
  </Source>
</ValidationScript>
<Button action="next" label="Rejected"/>
2 Likes

Validation scripts run after the button-click in any case, so you won’t have the option to disable the buttons.

OK, I get it! Thanks Devin and jarin…still a rookie at this…

The script is still causing an error in the xml file within the debug object. What am i doing wrong?

Change all && to &amp;&amp; So the script will look something like this

<ValidationScript>
  <Source>
  import sailpoint.object.Form.Button;
  
  Button button = form.getClickedButton();
  if (button != null) {
    if (button.getAction() != null &amp;&amp; button.getLabel() != null &amp;&amp; button.getAction().equalsIgnoreCase("next")
        &amp;&amp; button.getLabel().equalsIgnoreCase("Rejected")){
        if (value == null || value.isEmpty() || value.equals("") || value.length() <= 0) {
                  return "Please enter comments for rejection.";
        }
    }
  }
  </Source>
</ValidationScript>

The script is still not saving due to something has to be edited incorrectly.

      </Attributes>
    </Field>
    <Field displayName="Comments" name="comments" required="true" type="string">
    	<ValidationScript>
  			<Source>
 	 			import sailpoint.object.Form.Button;
  
  			Button button = form.getClickedButton();
  			if (button != null) {
  			  if (button.getAction() != null &amp;&amp; button.getLabel() != null &amp;&amp; button.getAction().equalsIgnoreCase("next")
        			&amp;&amp; button.getLabel().equalsIgnoreCase("Rejected")){
        			if (value == null || value.isEmpty() || value.equals("") || value.length() <= 0) {
                  return "Please enter comments for rejection.";
       			 }
    			}
  			}
  			</Source>
			</ValidationScript>
  </Section>
  <Button action="back" label="Rejected"/>
  <Button action="next" label="Approved"/>
</Form>

You can try changing action for Reject button to next

Hi Jarin,

It still did not work because the error message comes up which prevents me from saving it.

Are you guys allowed to have video meetings?

@derrickthomasvdot

You have to add closing tag for field. </Field> after </Validation Script> tag

</Attributes>
    </Field>
    <Field displayName="Comments" name="comments" required="true" type="string">
    	<ValidationScript>
  			<Source>
 	 			import sailpoint.object.Form.Button;
  
  			Button button = form.getClickedButton();
  			if (button != null) {
  			  if (button.getAction() != null &amp;&amp; button.getLabel() != null &amp;&amp; button.getAction().equalsIgnoreCase("next")
        			&amp;&amp; button.getLabel().equalsIgnoreCase("Rejected")){
        			if (value == null || value.isEmpty() || value.equals("") || value.length() <= 0) {
                  return "Please enter comments for rejection.";
       			 }
    			}
  			}
  			</Source>
			</ValidationScript>
			</Field>
  </Section>
  <Button action="back" label="Rejected"/>
  <Button action="next" label="Approved"/>
</Form>

Still same error.

My bad. Since you are updating from debug < should be replaced by &lt;

</Attributes>
    </Field>
    <Field displayName="Comments" name="comments" required="true" type="string">
    	<ValidationScript>
  			<Source>
 	 			import sailpoint.object.Form.Button;
  
  			Button button = form.getClickedButton();
  			if (button != null) {
  			  if (button.getAction() != null &amp;&amp; button.getLabel() != null &amp;&amp; button.getAction().equalsIgnoreCase("next")
        			&amp;&amp; button.getLabel().equalsIgnoreCase("Rejected")){
        			if (value == null || value.isEmpty() || value.equals("") || value.length() &lt;= 0) {
                  return "Please enter comments for rejection.";
       			 }
    			}
  			}
  			</Source>
	      </ValidationScript>
	</Field>
  </Section>
  <Button action="next" label="Rejected"/>
  <Button action="next" label="Approved"/>
</Form>

If you are still facing issues after this, I would suggest you share the xml file with us so that we can check and fix it.

Next time use
Util.isNullOrEmpty(value) instead of that long if condition :wink:
This makes it better readable, fully tested by SailPoint, shorter and nu XML encoding issues :wink:

— Remold

1 Like

I was able to finally save the xml but when the Rejected button is selected, it still goes back to requestor automatically without asking for a comment.

I have attached the entire xml file for further investigation.

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Form PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<Form created="1654030676125" id="7f000001811b181881811be9309d03c0" modified="1691418349165" name="Create Identity Admin Approval Form" type="Workflow">
  <Attributes>
    <Map>
      <entry key="pageTitle" value="Create Identity Admin Approval Form"/>
    </Map>
  </Attributes>
  <Description>Form to create VDOT Identity</Description>
  <Section label="Review User Details" name="userConfirmation">
    <Field displayName="Statewide ID" name="statewide_ID" required="true" type="string">
      <Attributes>
        <Map>
          <entry key="readOnly" value="true"/>
        </Map>
      </Attributes>
    </Field>
    <Field displayName="First Name" helpKey="First name of the user" name="firstname" postBack="true" required="true" type="string">
      <Attributes>
        <Map>
          <entry key="readOnly" value="true"/>
        </Map>
      </Attributes>
    </Field>
    <Field displayName="Middle Name" name="middleName" type="string">
      <Attributes>
        <Map>
          <entry key="readOnly" value="true"/>
        </Map>
      </Attributes>
    </Field>
    <Field displayName="Last Name" helpKey="Last name of the user" name="lastname" postBack="true" required="true" type="string">
      <Attributes>
        <Map>
          <entry key="readOnly" value="true"/>
        </Map>
      </Attributes>
    </Field>
    <Field displayName="Preferred Name" displayOnly="true" name="preferredName" type="string">
      <Attributes>
        <Map>
          <entry key="readOnly" value="true"/>
        </Map>
      </Attributes>
    </Field>
    <Field displayName="Display Name" displayOnly="true" dynamic="true" helpKey="Combination of First and Last name" name="displayName" postBack="true" required="true" type="string">
      <Attributes>
        <Map>
          <entry key="readOnly" value="true"/>
        </Map>
      </Attributes>
    </Field>
    <Field displayName="Email Address" helpKey="The VDOT user’s email address" name="email" required="true" type="string"/>
    <Field displayName="inactive" displayOnly="true" name="inactive" type="boolean" value="False">
      <Attributes>
        <Map>
          <entry key="readOnly" value="true"/>
        </Map>
      </Attributes>
    </Field>
    <Field displayName="User Type" helpKey="– Choose from the following in the dropdown: Employee, Staff Aug or Service Delivery Personnel" name="type_display" required="true" type="string">
      <Attributes>
        <Map>
          <entry key="readOnly" value="true"/>
        </Map>
      </Attributes>
    </Field>
    <Field displayName="Job Title" name="title" type="string">
      <Attributes>
        <Map>
          <entry key="readOnly" value="true"/>
        </Map>
      </Attributes>
    </Field>
    <Field displayName="Effective Date" helpKey="The date that user will be enabled in the SailPoint IIQ" name="effectiveDate" type="date">
      <Attributes>
        <Map>
          <entry key="readOnly" value="true"/>
        </Map>
      </Attributes>
    </Field>
    <Field displayName="Contact Phone" name="phone" type="string">
      <Attributes>
        <Map>
          <entry key="readOnly" value="true"/>
        </Map>
      </Attributes>
    </Field>
    <Field displayName="Work Location" helpKey="Transportation Operations Center where the user" name="region" required="true" type="string">
      <Attributes>
        <Map>
          <entry key="readOnly" value="true"/>
        </Map>
      </Attributes>
    </Field>
    <Field displayName="Supervisor" helpKey="The VDOT user’s manager or whom they report to" name="manager" required="true" type="sailpoint.object.Identity">
      <Attributes>
        <Map>
          <entry key="readOnly" value="true"/>
        </Map>
      </Attributes>
    </Field>
    <Field displayName="Work Address" name="workAddress" type="string">
      <Attributes>
        <Map>
          <entry key="readOnly" value="true"/>
        </Map>
      </Attributes>
    </Field>
    <Field displayName="TOC ID" helpKey="Local TOC user name" name="regionalId" required="true" type="string">
      <Attributes>
        <Map>
          <entry key="hidden">
            <value>
              <Script>
                <Source>if(region!=null &amp;&amp; region.equals("Statewide/Central Office"))
return true;
else
return false;</Source>
              </Script>
            </value>
          </entry>
          <entry key="readOnly" value="true"/>
        </Map>
      </Attributes>
    </Field>
    <Field displayName="Districts" helpKey="The VDOT District in which the user works" multi="true" name="district" required="true" type="string">
      <Attributes>
        <Map>
          <entry key="readOnly" value="true"/>
        </Map>
      </Attributes>
    </Field>
    <Field displayName="Background Check Completed" name="backgroundCheck" type="string">
      <Attributes>
        <Map>
          <entry key="readOnly" value="true"/>
        </Map>
      </Attributes>
    </Field>
    <Field displayName="Background Check Date" name="backgroundCheckDate" type="date">
      <Attributes>
        <Map>
          <entry key="hidden">
            <value>
              <Script>
                <Source>if(backgroundCheck==true)
return false;
else 
return true;</Source>
              </Script>
            </value>
          </entry>
          <entry key="readOnly" value="true"/>
        </Map>
      </Attributes>
    </Field>
    <Field displayName="Comments" name="comments" required="true" type="string">
      <ValidationScript>
        <Source>
                            import sailpoint.object.Form.Button;
  
                         Button button = form.getClickedButton();
                         if (button != null) {
                        if (button.getAction() != null &amp;&amp; button.getLabel() != null &amp;&amp; button.getAction().equalsIgnoreCase("next")
                               &amp;&amp; button.getLabel().equalsIgnoreCase("Rejected")){
                                if (value == null || value.isEmpty() || value.equals("") || value.length() &lt;= 0) {
                  return "Please enter comments for rejection.";
                          }
                        }
                       }
                        </Source>
      </ValidationScript>
    </Field>
  </Section>
  <Button action="back" label="Rejected"/>
  <Button action="next" label="Approved"/>
</Form>