Predeleagation Rule V2

Good mornning community

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“

and this is my rule

		
´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´
        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?

thanks community

Hi @BrianJ ,

you can modify the if condition to get only the users who are in only one workgroup and check if the workgroup is equals to executiveWorkGroup.

if(userGroup!=null && (userGroup.size()==1)) {

Hi Brian,

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.

Good Afternoon @naveenkumar3

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“

The code looks okay to me, it could be a data issue. Can you try a test run on any other identity ?? and then confirm??

Hello good mornning @naveenkumar3

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“

if(isExecutiveMember && !hasOtherWorkgroups) {
		customLog.warn("El certificador "+duenoActual.getName()+
				"es miembro de "+executiveWorkGroup+"delegado a: "+baWorkGroup);
		resultado.put("recipientName",baWorkGroup);
		resultado.put("reassign",Boolean.TRUE);

sorry, I did not understand. Where exactly you are seeing the issue?? if you can share me the loggers. I can easily troubleshoot it.

Good Mornning @naveenkumar3,

Sorry to test late I couldn’t did tests early, I attached a word document , I’ll do another test if I have another idea :light_bulb:

test (1).docx (2.9 MB)

Ohk, I tried understanding it as per the word document you attached. Can you please update the below code and test it. Hop this works for you.

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 shouldPredelegate = 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());
    
    // Check if THIS specific certification entity is for the Executive workgroup
    if(ce.getTargetName() != null && executiveWorkGroup.equals(ce.getTargetName())) {
        customLog.warn("Esta certificación es para el workgroup: " + executiveWorkGroup);
        shouldPredelegate = true;
    } else if(ce.getTargetDisplayName() != null && executiveWorkGroup.equals(ce.getTargetDisplayName())) {
        customLog.warn("Esta certificación es para el workgroup (DisplayName): " + executiveWorkGroup);
        shouldPredelegate = true;
    } else {
        customLog.warn("Esta certificación NO es para Executive workgroup. TargetName: " + 
                      ce.getTargetName() + ", TargetDisplayName: " + ce.getTargetDisplayName());
    }
    
} else {
    customLog.warn("La variable ce es null");
}

if(shouldPredelegate && duenoActual != null) {
    customLog.warn("PREDELEGANDO certificación de " + executiveWorkGroup + 
                  " del usuario " + duenoActual.getName() + " hacia: " + baWorkGroup);
    resultado.put("recipientName", baWorkGroup);
    resultado.put("reassign", Boolean.TRUE);
} else {
    customLog.warn("NO se predelega - se mantiene comportamiento por defecto (manager)");
}

customLog.info("predelegation manager rule : End");
return resultado;

Good Afternoon @naveenkumar3

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

´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´

if(ce.getTargetName() != null && executiveWorkGroup.equals(ce.getTargetName())) {
customLog.warn("Esta certificación es para el workgroup: " + executiveWorkGroup); shouldPredelegate = true; }

else if(ce.getTargetDisplayName() != null && executiveWorkGroup.equals(ce.getTargetDisplayName())) { customLog.warn("Esta certificación es para el workgroup (DisplayName): " + executiveWorkGroup); shouldPredelegate = true;

else { customLog.warn("Esta certificación NO es para Executive workgroup. TargetName: " + ce.getTargetName() + ", TargetDisplayName: " + ce.getTargetDisplayName());

‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘

I have and idea let me see if it’s works

Yeah sure try, Because I am not able to understand what is the requirement

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