Which IIQ version are you inquiring about?
Version 8.3
Share all details about your problem, including any error messages you may have received
I’m currently developing a report to display the identities that are going to become a leaver. I want to display the identities whose “endDate” is in the next 30 days.
I added the following parameter to the QueryParameters to run a quick test:
<Parameter property="endDate">
<QueryScript>
<Source><![CDATA[
import sailpoint.object.Filter;
import java.util.Date;
Date currentDate = new Date();
queryOptions.addFilter(Filter.lt("endDate", currentDate));
return queryOptions;]]>
</Source>
</QueryScript>
</Parameter>
From this code, I’m getting the following error:
sailpoint.tools.GeneralException: class java.util.Date cannot be cast to class java.lang.String
Is it possible to use Dates in Filters in order to achieve the desired behavior?
From what I can tell the “endDate” should be in Date format. I just tested the following script, and it shows as Date. Also, the filter doesn’t throw the error in the script.
import sailpoint.object.Identity;
import sailpoint.object.Filter;
import java.util.Date;
Date d = new Date();
log.error(d);
log.error(d.getClass());
Identity i = context.getObjectByName(Identity.class, "IIQtest02_DEV");
log.error(i.getAttribute("endDate"));
log.error(i.getAttribute("endDate").getClass());
Filter f = Filter.lt("endDate", d);
log.error(f);
These are the logs:
Shouldn’t I be able to used this filter in the report?
From the Advanced Analytics, we can see that the “endDate” is actually stored as a String, with the representation of the endDate in Milliseconds:
For completeness, I leave below the final configuration of the parameter:
<Parameter property="endDate">
<QueryScript>
<Source><![CDATA[
import java.util.Calendar;
import java.util.Date;
import sailpoint.object.Filter;
Date currentDate = new Date();
Calendar start = Calendar.getInstance(), end = Calendar.getInstance();
start.setTime(currentDate);
start.add(Calendar.DATE, -30);
end.setTime(currentDate);
queryOptions.addFilter(Filter.ge("endDate", start.getTimeInMillis().toString()));
queryOptions.addFilter(Filter.le("endDate", end.getTimeInMillis().toString()));
return queryOptions;]]>
</Source>
</QueryScript>
</Parameter>
Thanks for the support @pravin_ranjan
1 Like