We have a requirement of report with the records from spt_identity table where column extended1 stores date in string format.
since extended1 storing in string and I wanted to generate the report using thequeryParameter filter source =“Identity”. This is not working data stored in String and Filter I am passing the as below.
Because extended1 is stored as a string in dd/MM/yyyy format, a direct Filter.ge("extended1", calendar.getTime()) will not work correctly in IdentityIQ. The comparison is done lexically (as a string) rather than as an actual date. Below approach you can use to handle this limitation.
Parse the String in Memory, Then Filter Manually
Workaround—though not always recommended—would be to load the identities first (with a broader filter or no filter on extended1), parse the date string from extended1 in Beanshell (or Java), and then discard records that do not meet the requirement.
Example (pseudocode in Beanshell):
import java.text.SimpleDateFormat;
import java.util.Date;
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
Date cutoffDate = calendar.getTime(); // whatever your calendar is
List identities = context.getObjects("sailpoint.object.Identity", yourQueryOptions);
Iterator it = identities.iterator();
while (it.hasNext()) {
Identity idObj = (Identity) it.next();
String dateStr = idObj.getString("extended1");
if (dateStr != null) {
try {
Date extDate = sdf.parse(dateStr);
if (extDate.before(cutoffDate)) {
it.remove(); // remove identity from the list
}
} catch (Exception e) {
// invalid date in extended1? remove or keep, your choice
it.remove();
}
} else {
it.remove();
}
}
// Now identities list contains only those whose extended1 >= your cutoffDate
return identities;
Pros
You can do real Date comparisons.
No changes to the DB schema or data format needed.
Cons
Potentially expensive: You’re loading more rows than you need and filtering in-memory.
Doesn’t leverage DB filtering (not ideal for large Identity populations).
@kolipakularaviturnkey As the data is in string and you are passing long value so it will not work.
There is 2 ways:-
You can create a method and get string value Date in List which you want and then use filter.in(“Extended1”,list); this will be huge in case if you have more days to be calculated if you have upto 10 or twenty then u can use this.
If you have dba team you can ask them that we need the query where we have date between need to get output and compare those with string format. You can search in AI tool those query and u can use Context.search("sql : "+sql,null,null)
rather context.search(identity.class
so it will help you to find all the required data.