I’m looking for guicance on what I may be doing wrong. If I have a syntax error, the aggregation will fail. So the rule seems to be running, but I never seem to be able to update the email and loginId values to be all lowercase.
The schema and naming is correct. I validated it with a Python script capturing the response JSON.
Below is the rule:
import sailpoint.object.Application;
import sailpoint.connector.webservices.EndPoint;
import sailpoint.connector.webservices.WebServicesClient;
import sailpoint.tools.Util;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
Map execute(
Application application,
EndPoint requestEndPoint,
List processedResponseObject,
String rawResponseObject,
WebServicesClient restClient) {
log.error("AfterOperationRule: Entering rule with Rebuild Strategy.");
if (processedResponseObject == null || processedResponseObject.isEmpty()) {
log.error("AfterOperationRule: processedResponseObject is null or empty. Exiting.");
return null;
}
// 1. Create a new, empty list to hold our editable account maps.
List newList = new ArrayList();
for (Map account : processedResponseObject) {
// 2. For each account, create a new, editable HashMap by copying the original.
Map newMutableAccount = new HashMap(account);
// --- Logic for handling the email attribute on the NEW map ---
String emailAttributeName = "email";
if (newMutableAccount.containsKey(emailAttributeName)) {
Object emailValue = newMutableAccount.get(emailAttributeName);
if (emailValue != null && emailValue instanceof String) {
String originalEmail = (String) emailValue;
String normalizedEmail = originalEmail.trim().toLowerCase();
if (!originalEmail.equals(normalizedEmail)) {
log.error("AfterOperationRule: Updating email on mutable copy.");
newMutableAccount.put(emailAttributeName, normalizedEmail);
}
}
}
// --- Logic for handling the loginId attribute on the NEW map ---
String loginIdAttributeName = "loginId";
if (newMutableAccount.containsKey(loginIdAttributeName)) {
Object loginIdValue = newMutableAccount.get(loginIdAttributeName);
if (loginIdValue != null && loginIdValue instanceof String) {
String originalLoginId = (String) loginIdValue;
String normalizedLoginId = originalLoginId.trim().toLowerCase();
if (!originalLoginId.equals(normalizedLoginId)) {
log.error("AfterOperationRule: Updating loginId on mutable copy.");
newMutableAccount.put(loginIdAttributeName, normalizedLoginId);
}
}
}
// 3. Add the fully modified, mutable account to our new list.
newList.add(newMutableAccount);
}
// 4. Create the final map to return.
Map returnMap = new HashMap();
// 5. Put our NEW list (not the original) into the map under the "items" key.
returnMap.put("items", newList);
log.error("AfterOperationRule: Exiting rule. Returning rebuilt map with key 'items'.");
return returnMap;
}
``
Here is a sample output of the JSON response.
```
{
“allowAdhocMatching”: false,
“allowIntercompanySettlement”: false,
“allowUserMentions”: true,
“allowUserToEditIntercompanyConfig”: false,
“allowUserToEditJournalConfig”: false,
“annualHours”: 0,
“created”: “8/5/2022 3:11:28 PM”,
“defaultRoleId”: null,
“email”: “[email protected]”,
“firstName”: “Olga”,
“fullName”: “Smith, Olga”,
“id”: 27,
“isActive”: true,
“jobId”: null,
“jobTitle”: null,
“lastName”: “Smith”,
“lastUpdated”: “12/26/2024 2:56:13 PM”,
“loginId”: “[email protected]”,
“phoneNumber”: null,
“referenceField1”: “”,
“referenceField2”: “”,
“referenceField3”: “”,
“requiresJournalReviewer”: false,
“supervisor”: null,
“timeZoneId”: 15,
“allowUserToAccessJournalAnalyser”: false
}
```
the source connector is using items.