If you have multiple statuses on end source for active or inactive status then current webservice source lacks the capability to configure this. You can only specify one value as active status.
To reduce the repetitive effort of doing the same task I developed generic rule which is very basic and you do not need to change anything to use it for your environment.
//These are 3 attributes which needs to be added in connectorAttributes on source json so rule can read them. enablelist and disablelist would be json list
String statusAttribute=(String) application.getAttributeValue("statusAttribute");
List enableList=(List) application.getAttributeValue("enableValues");
List disableList=(List) application.getAttributeValue("disableValues");
for(Object object: processedResponseObject) {
Map userMap=(Map)object;
if(userMap.containsKey(statusAttribute)) {
String statusValue=((String) userMap.get(statusAttribute)).toLowerCase();
if(enableList != null) {
for(String str: enableList) {
if(str.toLowerCase().equalsIgnoreCase(statusValue)) {
userMap.put("IIQDisabled", false);
break;
//if we get one value compared from the enable list then no need to check for rest of them
}
}
}
if(disableList != null) {
for(String str: disableList) {
if(str.toLowerCase().equalsIgnoreCase(statusValue)) {
userMap.put("IIQDisabled", true);
break;
//if we get one value compared from the disable list then no need to check for rest of them
}
}
}
}
}
You need to add 3 attributes under source json using patch api. The attributes which need to be added are.
-
statusAttribute: The value of this attribute is the one which you have defined in your response mapping on left side and not the attribute name from end source json response.
-
enableList : if your end system has 3 different status for active account then enter it as json list.
e.g. body for json patch:
[
{
"op": "add",
"path": "/connectorAttributes/enableValues",
"value": ["active","activationSent","Pending"]
}
]
- disableList: list of statuses which define if account is disabled.
All comparison is case insensitive.
Do let me know if anyone faces any issue in using the rule snippet.