Currently I made the next rule for certificationmanager type, this rule predelegate the records if the certifier belong’s to the workgroup “Workgroup Executive Members“ to workgroup “BA_TEST“, but Im face in off another issue, if some user who need´s the review access and has 2 workgroups or more and one of this workgroups is “Workgroup Executive Members“ the record completly predelagates to BA_TEST.
the next two image’s show’s the user who belongs to “Workgroup Executive Members“and this record predeleagates to “BA_TEST“ due to the certifier belongs “Workgroup Executive Members“
´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´
Logger customLog = Logger.getLogger("com.Santander.CustomLog");
customLog.info("predelegation manager rule : Start");
String executiveWorkGroup = "Santander Workgroup Executive Members";
String baWorkGroup = "TEST_BA";
Map resultado = new HashMap();
Identity duenoActual = null;
boolean bandera = false;
CertificationEntity ce = (CertificationEntity)entity;
if(ce != null) {
String currentIdentity = ce.getIdentity();
duenoActual = context.getObjectByName(Identity.class,currentIdentity);
customLog.warn("actual dueño de la certificacion: "+ce.getName());
}else if(ce == null) {
customLog.warn("la variable ce es null");
}
if(duenoActual != null) {
List<Identity> userGroup = duenoActual.getWorkgroups();
if(userGroup !=null) {
for(Identity wg : userGroup) {
if(executiveWorkGroup.equals(wg.getName())) {
bandera = true;
break;
}
}
}
if(bandera) {
customLog.warn("El certificador "+duenoActual.getName()+
"es miembro de "+executiveWorkGroup+"delegado a: "+baWorkGroup);
resultado.put("recipientName",baWorkGroup);
resultado.put("reassign",Boolean.TRUE);
} else {
customLog.warn("El cerificador "+duenoActual.getName()+
" no pertenece al workgroup: "+executiveWorkGroup);
}
}else {
customLog.warn("Owner is not a identity "+ duenoActual.getClass().getName());
}
return resultado;
´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´
How could I avoid this, and just only predelegate only the user who belong’s to “Workgroup Executive Members“ or wich library coud I use to read each identity and predelagate to BA_TEST?
I looked at your rule and made changes to your rule, to handle your scenario. Please use the below rule and it should fix your issue. Please let me know if your are still having the issue, If the rule fixes your issue, please mark the post as solution.
Logger customLog = Logger.getLogger("com.Santander.CustomLog");
customLog.info("predelegation manager rule : Start");
String executiveWorkGroup = "Santander Workgroup Executive Members";
String baWorkGroup = "TEST_BA";
Map resultado = new HashMap();
Identity duenoActual = null;
boolean isExecutiveMember = false;
boolean hasOtherWorkgroups = false;
CertificationEntity ce = (CertificationEntity)entity;
if(ce != null) {
String currentIdentity = ce.getIdentity();
duenoActual = context.getObjectByName(Identity.class, currentIdentity);
customLog.warn("actual dueño de la certificacion: " + ce.getName());
} else if(ce == null) {
customLog.warn("la variable ce es null");
}
if(duenoActual != null) {
List<Identity> userGroup = duenoActual.getWorkgroups();
if(userGroup != null && !userGroup.isEmpty()) {
customLog.warn("User " + duenoActual.getName() + " belongs to " + userGroup.size() + " workgroups");
for(Identity wg : userGroup) {
if(executiveWorkGroup.equals(wg.getName())) {
isExecutiveMember = true;
} else {
hasOtherWorkgroups = true;
}
}
// Only predelegate if user is ONLY in Executive workgroup and no other workgroups
if(isExecutiveMember && !hasOtherWorkgroups) {
customLog.warn("El certificador " + duenoActual.getName() +
" es miembro EXCLUSIVO de " + executiveWorkGroup + " delegado a: " + baWorkGroup);
resultado.put("recipientName", baWorkGroup);
resultado.put("reassign", Boolean.TRUE);
} else if(isExecutiveMember && hasOtherWorkgroups) {
customLog.warn("El certificador " + duenoActual.getName() +
" pertenece a " + executiveWorkGroup + " pero también tiene otros workgroups, NO se delega");
} else {
customLog.warn("El certificador " + duenoActual.getName() +
" no pertenece al workgroup: " + executiveWorkGroup);
}
} else {
customLog.warn("El certificador " + duenoActual.getName() + " no tiene workgroups asignados");
}
} else {
customLog.warn("Owner is not a identity");
}
return resultado;
You’re predelegating the entire record because your rule triggers if the user belongs to any workgroup matching "Workgroup Executive Members".
To fix this, check each workgroup individually and only predelegate the part of the record tied to "Workgroup Executive Members", leaving other workgroups untouched. Use Identity.getWorkgroups() or IdentityService.getWorkgroups(identity) for precise checks.
Sorry to reply you late, I did test today with the updated you did on my rule and it almost work’s, the rule only predelagates when the user has the workgroup “Workgroup Executive Members“ but if the user has this workgroup and another workgrorup the record didn’t predelagate to the “TEST_BA” this is my result test, look this user only has the “Workgroup Executive Members“ an in the second image the user has three workgroups and one of them is Workgroup Executive Members this only record didn’t predelagate to “TEST_BA“
I made another two test with the update and I saw is not doing anythig in this part of the “if“ due to doesn’t have the map on “if”, the user has 2 or more workgroups and one of them is “executive workgroup“ I share you the outpout log this is for the first one try and in the second test I made, I put the map on that “if”, the predelagation work’s but all of the records if the user has “executive workgroup“ and the other workgroups, there is way if the user has “executive workgroup“ and more workgroups only predelagate the record with workgroup “executive workgroup“
I did a new test with new update you did, but isn´t working on this part, due to you are retriving the user with getTargetName() and whit getTargetDisplayName() you are recover the complete name of the user who needs the certification and in the first “if“ and “else if“, those instructions alway’s set it on false due to on the condition you have the function executiveWorkGroup.equals() you are reading the workgroup not the user, such as you can see on the log’s the next user C046401 has the “executive workgroup“ and doesn’t predelegate to the TEST_BA workgroup