Custom report form with multiple parameters filter

Hello Sailpoint’s community.

I am creating a custom report with a form to allow a user to enter a date. Since IIQ’s OOTB date field only allows input of days/months/years but not hours/minutes, I had to add 2 more fields in my form.

The problem is that I can’t send multiple values ​​from the form to the custom report in a single query parameter. So I tried to add another field that concat date+hours+minutes to have only one field to send, but this time I just can’t send that parameter to my report because value=“ref:fieldName” is not possible as I build the value using a script to concat the date and the hours/minutes.

Here is the form’s XML:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Form PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<Form name="Custom-Form-LastUpdatedAccounts" type="Report">
  <Attributes>
    <Map>
      <entry key="pageTitle" value="Custom-Form-LastUpdatedAccounts"/>
    </Map>
  </Attributes>
  <Description>Configuration form for LastUpdatedAccounts report</Description>
  <Section columns="3" label="Custom options" name="customOptions">
    <Field columnSpan="1" displayName="Start date" name="startDate" postBack="true" required="true" type="date" value="ref:startDate"/>
    <Field columnSpan="1" displayName="Start hour" name="startHour" postBack="true" required="true" type="string" value="ref:startHour">
      <AllowedValuesDefinition>
        <Script>
          <Source><![CDATA[
            List allowedValues = Arrays.asList("00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23");
            return allowedValues;
          ]]></Source>
        </Script>
      </AllowedValuesDefinition>
    </Field>
    <Field columnSpan="1" displayName="Start minutes" name="startMinutes" postBack="true" required="true" type="string" value="ref:startMinutes">
      <AllowedValuesDefinition>
        <Script>
          <Source><![CDATA[
            List allowedValues = Arrays.asList("00","05","10","15","20","25","30","35","40","45","50","55");
            return allowedValues;
          ]]></Source>
        </Script>
      </AllowedValuesDefinition>
    </Field>
    <Field columnSpan="3" hidden="true" displayName="Start" dynamic="true" name="start" required="true" type="date">
      <Attributes>
        <Map>
          <entry key="readOnly" value="true"/>
        </Map>
      </Attributes>
      <Script>
        <Source><![CDATA[
          Date startDate = form.getField("startDate").getValue();
          String startHour = form.getField("startHour").getValue();
          String startMinutes = form.getField("startMinutes").getValue();

          Calendar calendar = Calendar.getInstance();
          calendar.setTime(startDate);
          if (startHour != null)
          {
            calendar.add(Calendar.HOUR_OF_DAY, Integer.parseInt(startHour));
          }
          if (startMinutes != null)
          {
            calendar.add(Calendar.MINUTE, Integer.parseInt(startMinutes));
          }
          return calendar.getTime();
        ]]></Source>
      </Script>
    </Field>
    <Field columnSpan="1" displayName="End date" name="endDate" postBack="true" required="true" type="date" value="ref:endDate">
      <ValidationScript>
        <Source><![CDATA[
          import sailpoint.object.Field;
          import sailpoint.tools.Message;

          List messages = new ArrayList();

          Field startDateField = form.getField("startDate");
          Date startDate = startDateField.getValue();
          if (startDate != null && (startDate.after(value) || startDate.equals(value)))
          {
            messages.add(Message.localize("End date must be after the start date")); 
          }
          return messages;
        ]]></Source>
      </ValidationScript>
    </Field>
    <Field columnSpan="1" displayName="End hour" name="endHour" postBack="true" required="true" type="string" value="ref:endHour">
      <AllowedValuesDefinition>
        <Script>
          <Source><![CDATA[
            List allowedValues = Arrays.asList("00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23");
            return allowedValues;
          ]]></Source>
        </Script>
      </AllowedValuesDefinition>
    </Field>
    <Field columnSpan="1" displayName="End minutes" name="endMinutes" postBack="true" required="true" type="string" value="ref:endMinutes">
      <AllowedValuesDefinition>
        <Script>
          <Source><![CDATA[
            List allowedValues = Arrays.asList("00","05","10","15","20","25","30","35","40","45","50","55");
            return allowedValues;
          ]]></Source>
        </Script>
      </AllowedValuesDefinition>
    </Field>
    <Field columnSpan="3" hidden="true" displayName="End" dynamic="true" name="end" required="true" type="date">
      <Attributes>
        <Map>
          <entry key="readOnly" value="true"/>
        </Map>
      </Attributes>
      <Script>
        <Source><![CDATA[
          Date endDate = form.getField("endDate").getValue();
          String endHour = form.getField("endHour").getValue();
          String endMinutes = form.getField("endMinutes").getValue();

          Calendar calendar = Calendar.getInstance();
          calendar.setTime(endDate);
          if (endHour != null)
          {
            calendar.add(Calendar.HOUR_OF_DAY, Integer.parseInt(endHour));
          }
          if (endMinutes != null)
          {
            calendar.add(Calendar.MINUTE, Integer.parseInt(endMinutes));
          }
          return calendar.getTime();
        ]]></Source>
      </Script>
    </Field>
  </Section>
</Form>

Can anyone help me on this?

Thank you in advance.

Mathieu G

Problem solved. I can finally send multiple values ​​from the form to the custom report. I just need to use the arguments global variable in my report.

Here is the code example :

<QueryParameters>
	<Parameter>
		<QueryScript>
			<Source>
			<![CDATA[
			import sailpoint.object.QueryOptions;
			import sailpoint.object.Filter;

			// The second step is to build the startDate filter
			// Use the 'arguments' global variable to get values from the form
			Date startDate = arguments.getDate("startDate");
			String startHour = arguments.getString("startHour");
			String startMinutes = arguments.getString("startMinutes");

			Calendar calendar = Calendar.getInstance();
			calendar.setTime(startDate);
			if (startHour != null)
			{
				calendar.add(Calendar.HOUR_OF_DAY, Integer.parseInt(startHour));
			}
			if (startMinutes != null)
			{
				calendar.add(Calendar.MINUTE, Integer.parseInt(startMinutes));
			}
			Date finalStartDate = calendar.getTime();
			queryOptions.addFilter(Filter.ge("created", finalStartDate));

			// The third step is to build the endDate filter
			// Use the 'arguments' global variable to get values from the form
			Date endDate = arguments.getDate("endDate");
			String endHour = arguments.getString("endHour");
			String endMinutes = arguments.getString("endMinutes");

			Calendar calendar = Calendar.getInstance();
			calendar.setTime(endDate);
			if (endHour != null)
			{
				calendar.add(Calendar.HOUR_OF_DAY, Integer.parseInt(endHour));
			}
			if (endMinutes != null)
			{
				calendar.add(Calendar.MINUTE, Integer.parseInt(endMinutes));
			}
			Date finalEndDate = calendar.getTime();
			queryOptions.addFilter(Filter.le("created", finalEndDate));

			// Return queryOptions
			return queryOptions;
			]]>
			</Source>
		</QueryScript>
	</Parameter>
</QueryParameters>

Hope this helps people who have the same problem as me in the future.

Regards,

Mathieu G