Which IIQ version are you inquiring about?
8.4
Please share any images or screenshots, if relevant.
Hi Sailors,
I created a block of code to add an audit event to record the added and removed entitlements in a role. However, I found that the value shown is the entitlement object instead of the entitlement displayName. And the value shown is not full as well. I would like to know how I can retrieve the entitlement displayName from the object.
// Part 2. Audit profile differences (entitlements, constraints, etc.)
if (roleDifference != null && roleDifference.hasDifferences()) {
List profileDiffs = roleDifference.getProfileDifferences();
log.error("Profile differences found: Number of profileDiffs = " + (profileDiffs != null ? profileDiffs.size() : "null"));
if (profileDiffs != null && !profileDiffs.isEmpty()) {
hasChanges = true;
for (Object diffObj : profileDiffs) {
if (diffObj instanceof ProfileDifference) {
ProfileDifference diff = (ProfileDifference) diffObj;
log.error("Processing ProfileDifference for application: " + diff.getApplication());
// Process filter difference for entitlements/constraints
Difference filterDiff = diff.getFilterDifference();
if (filterDiff != null) {
Object oldObj = filterDiff.getOldValue();
Object newObj = filterDiff.getNewValue();
// Check for removed and added values
if (oldObj != null) {
String removedValue = oldObj.toString();
filterDiff.addRemovedValue(removedValue); // Store removed value
log.error("Removed Value: " + removedValue);
}
if (newObj != null) {
String addedValue = newObj.toString();
filterDiff.addAddedValue(addedValue); // Store added value
log.error("Added Value: " + addedValue);
}
log.error("Filter difference found");
Object oldObj = filterDiff.getOldValue();
log.error("Old filter value class: " + (oldObj != null ? oldObj.getClass().getName() : "null"));
log.error("Old filter value: " + (oldObj != null ? oldObj.toString() : "null"));
Object newObj = filterDiff.getNewValue();
log.error("New filter value class: " + (newObj != null ? newObj.getClass().getName() : "null"));
log.error("New filter value: " + (newObj != null ? newObj.toString() : "null"));
// Create AuditEvent
AuditEvent event = new AuditEvent();
event.setAction("RoleAttributeChange");
event.setSource(launcher);
event.setTarget(roleObject.getName());
event.setAttributeName("Profile Entitlement Changes");
event.setString1("Added Value: " + (newObj != null ? newObj.toString() : "null"));
event.setString2("Removed Value: " + (oldObj != null ? oldObj.toString() : "null"));
Auditor.log(event);
context.saveObject(event);
} else {
log.error("No filter difference found in this ProfileDifference");
}
}
}
context.commitTransaction(); // Commit after all events
}
} else {
log.error("No role differences or no hasDifferences");
}

