WebService Aggregation Be Array Instead Split to Each Entitlement

Hello Everyone, I have some question about my entitlements, why it’s look like array, but not split to each entitlement?

I tried to do the afterOperation rule, with this code

import java.util.*;

Map updatedMapInfo = new HashMap();

if (processedResponseObject != null) {
    for (Map iterateMap : processedResponseObject) {
        if (iterateMap != null) {
            Set keySet = iterateMap.keySet();
            for (Object keyObj : keySet) {
                String key = keyObj.toString();


                // Split role string into a List
                if (key.equals("role")) {
                    Object roleObj = iterateMap.get("role");
                    if (roleObj instanceof String) {
                        String roleStr = (String) roleObj;
                        List roleList = Arrays.asList(roleStr.split(","));
                        iterateMap.put("role", roleList);
                    }
                }
            }
        }
    }

    updatedMapInfo.put("data", processedResponseObject);
}

Map connectorStateMap = new HashMap();
connectorStateMap.put("refresh_token", "refreshTokenGeneratedInAfterRuleScript");
updatedInfoMap.put("connectorStateMap", connectorStateMap);

return updatedMapInfo;

It’s look like it send to ISC with array, i hope it split each entitlement but i got the array

this is my configure

remove multivalued for role, reset entitlements from VS code and rerun aggregation

Also you do not need to mention it as entitlement again. As you have already created this entitlement object

If that also does not work update your code to this and try once. I found some mistakes

import java.util.*;

Map updatedMapInfo = new HashMap();
List finalList = new ArrayList();

if (processedResponseObject != null) {
    for (Map iterateMap : processedResponseObject) {
        if (iterateMap != null) {
            Set keySet = iterateMap.keySet();

            for (Object keyObj : keySet) {
                String key = keyObj.toString();

                // Split role string into a List
                if (key.equals("role")) {
                    Object roleObj = iterateMap.get("role");

                    if (roleObj instanceof String) {
                        String roleStr = (String) roleObj;
                        Map roles = new HashMap();
                        roles.put("role", roleStr);
                        finalList.add(roleProduct);
                    }
                }
            }
        }
    }

    updatedMapInfo.put("data", finalList);
}

return updatedMapInfo;

Hi @udayputta , Sorry for late reply, this works, Thank you so much!

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.