Can we add time field to a form

Which IIQ version are you inquiring about?

8.5

we had a requirement to add a form field to input time in AM/PM format but wants a field that user can select time as date field instead of a string input field , it seems sailpoint doesn’t have default time type field . is it possible to add time selector to a form?

You can use type=“date”.

specifying type=“date” adds a calendar from which the date can be selected.

IQ’s Form field types (string, integer, boolean, date, secret, identity, etc.) don’t include a “time” type, and the standard type="date" field only renders the Ext JS date picker.

try below approach, and see if it resolves your requirement:

Use a type="string" field with displayType="select", populated via a Rule that returns time slots in AM/PM format.

<Field name="requestedTime" type="string" displayName="Requested Time" displayType="select">
    <Attributes>
        <Map>
            <entry key="allowedValuesDefinition">
                <value>
                    <RuleRef>
                        <Reference class="sailpoint.object.Rule" name="Time Rule"/>
                    </RuleRef>
                </value>
            </entry>
        </Map>
    </Attributes>
</Field>

attach below rule to populate

import java.text.SimpleDateFormat;
import java.util.*;

List times = new ArrayList();
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm a");
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);

for (int i = 0; i < 48; i++) {
    times.add(sdf.format(cal.getTime()));
    cal.add(Calendar.MINUTE, 30);
}
return times;

Hello Saipriya. @NikitaDeshmukh0811 type="date" only renders the calendar date picker, it won’t give a time selector. @naveenkumar3 rule approach should work well here. IIQ doesn’t have a native time field, so a string dropdown populated with time slots is the right workaround.

I would just place the RuleRef directly inside AllowedValuesDefinition (that’s the documented structure) and use displayType="combobox":

<Field name="requestedTime"
       type="string"
       displayName="Requested Time"
       displayType="combobox">
  <AllowedValuesDefinition>
    <RuleRef>
      <Reference class="sailpoint.object.Rule" name="Time Rule"/>
    </RuleRef>
  </AllowedValuesDefinition>
</Field>

If you would rather not create a separate Rule object, the same script can go inline inside AllowedValuesDefinition using a <Script> block instead of the <RuleRef>.

The selected value comes back as a plain string like 08:30 AM. If you need to combine it with a date field value later, make sure you parse both together into a proper date-time object in your workflow or rule, not just concatenate them as text.