Edit Identity form field mark as required

Which IIQ version are you inquiring about?

8.4p1 e243e6f4783-20240325-035201

Please share any images or screenshots, if relevant.

Hi SailPoint team,

We have a “Extend Account Expiration” under Manage Identity, which is default redirecting to “Edit Identity form” and it is a custom form not the default.

Here “New End Date” field should be required, I have tried marking it as required=true and added validation Rule in the form, it is not working. Please assist.

<Field displayName="New End Date" helpKey="New End Date" name="endDateDisplay" postBack="true" required="true" type="date">
      <ValidationScript>
        <Source>
          import java.util.Date;     
 if (value == null){
        return null;
      }
      
      Long newEndDate = value.getTime();
      Date today = new Date();
      Long now = today.getTime();

      if (now > (newEndDate + 86400000L)) {
      return "End date cannot be prior to today's date";
      }
      if (newEndDate > now + 31556952001L) {
        return "End date must be within 365 days of today's date";
      }
      else{
        return null;
      }
    </Source>
  </ValidationScript>
</Field>

are you getting any errors?

There is no error. When I click on submit with empty value in the field “New End Date”, Form is getting submitted with null value.

Are you calling any workflow on submit?

If you are calling any workflow, in that workflow, you can add your validation and these null checks. If the value is null and no new value, then keep the old value.

This logic can be added.

 if (value == null){
        return null;
 }

Here, if the user doesn’t enter a date, the value variable passed to the validation script is null. Since your script returns null when value is null, you’re implicitly telling IdentityIQ that the absence of a value constitutes successful validation.

Try this and let me know, maybe it will work :
if (value == null){
return "New End Date field is required.";
}

It worked. Thank you much @Hamza10 for the help.

Great
You are welcome :grinning_face: