JDBCBuildMap Rule issue

Which IIQ version are you inquiring about?

8.5

Please share any other relevant files that may be required (for example, logs).

*I am working on below JDBCBuilMap Rule. *
import sailpoint.connector.JDBCConnector;

import java.util.Map;

Map map = JDBCConnector.buildMapFromResultSet(result, schema);

// Read ID safely

String id = (String) map.get(“id”);

// Skip if id is missing

if (id == null) {

return null;     // safe skip

}

// Skip if id does not start with “1a”

if (!id.startsWith(“1a”)) {

return null;

}

// Return map for valid rows

return map;

Share all details about your problem, including any error messages you may have received.

It is failing as I am returning NULL for various conditions. I wanted to aggregate only those accounts whose id starts with “1a”. For this requirement I have written above rule but getting issue as I am returning null. Can anyone help me with this. Thank you!

Hi @toshal_selokar , can you add the following:

if(map == null) {
return null;
}
if (!id == null || id.length() == 0 ) {
return null;
}

Your map could be null if there are missing columns or bad data and your id could be empty instead of null.

1 Like

Instead of writing the build map rule, can you please fix your sql query " Simply add WHERE id LIKE '1a%' to your JDBC application’s SQL query.

If this works else use the below code, for returning empty map.

import sailpoint.connector.JDBCConnector;
import java.util.Map;
import java.util.HashMap;

Map map = JDBCConnector.buildMapFromResultSet(result, schema);

// Read ID safely
String id = (String) map.get("id");

// Skip if id is missing or doesn't start with "1a"
if (id == null || !id.startsWith("1a")) {
    // Return empty map - connector will typically skip empty maps
    return new HashMap();
}

// Return map for valid rows
return map;

Hi Naveen, we have tried with SQL query but for hands on I was trying both Customization and BuildMap way.
For me the customization rule was success but I haven’t been able to complete this task with BuildMap rule

Also we tried returning empty mal as well, but we got the error that the map is null. But still I will give it a try once more.

Sure Ryan, Thanks for your help. I will try this once.

yeah, let me know how it works.

Hi @naveenkumar3 , I tried returning new HashMap(); but it has ran into the RuntimeException. Index value for[id] on new object was null.

IIQ requiresthe identity attribute (in your case “id”) to be present in the returned map for indexing. When you return new HashMap() , it has no “id” field, causing the error. try the below one and let me know, if it is fixed.

import sailpoint.connector.JDBCConnector;
import java.util.Map;

Map map = JDBCConnector.buildMapFromResultSet(result, schema);


String id = (String) map.get("id");

// Skip if id is missing or doesn't start with "1a"
if (id == null || !id.startsWith("1a")) {
    return null;  
}


return map;

BuildMap cannot return null. You’ll get a strange exception if you try.

If you need to skip a row that’s missing a value, Customization is the place to do that, or in the SQL query itself.

Hi Devin,

I have already suggested that, and he has confirmed that, he is able to achieve it, via sql query and customization rule, but he wants to try with build map rule

Hi All, I was able to solve the issue with temporary fix i.e.,
import sailpoint.connector.JDBCConnector;

import sailpoint.object.Schema;
import java.util.Map;

import java.util.HashMap;

Map map = JDBCConnector.buildMapFromResultSet(result, schema);

if (map.get(“id”) == null || !map.get(“id”).toString().startsWith(“1a”)) {

Map ignoreMap = new HashMap();

ignoreMap.put(“id”, “IgnoreAccount”);

return ignoreMap;

}

return map;

Here the aggregartion is successful, it’s just one extra account gets created named IgnoreAccount with no data in it.

Hi @toshal_selokar , It is recommended to use aggregation rules for such requirements. so i will advise you to use the customization rule to achieve the expected results.

I would suggest Toshal, not to proceed with this solution. Try updating your sql query with the condition and it will work. Build Map rule evaluates every identity, so it can impact the performance

1 Like

Yea Samarth, I will be going with Customization rule only or SQL Statement.

We will be proceeding with the Customization or SQL.

not a recommended approach, better go with customisation rule.

Hi @toshal_selokar ,

Do not proceed with. this approach of adding the dummy account name in the map. You will end up aggregating account with the account name ‘IgnoreAccount‘ in SailPoint. Not recommended approach. Please go ahead with customization rule to implement this requirement.

Thanks,

Pallavi

3 Likes

Hi @pallavi , Thank you! I will be proceeding with Customization rule.