WebServiceAfterOperationRule in validations

Hi Team,

I’m trying to put some validations in WebServiceAfterOperationRule like below but somehow employeestatus Invalid updating for all users.

boolean invalidStatus= false; 
		
		String email = employeeEntry.get("emailAddress");
		String department = employeeEntry.get("orgLevel3Description");  
		String division = employeeEntry.get("orgLevel2Description");  
		String empStatus = employeeEntry.get("employeeStatus");	
		
			if(Util.isNullOrEmpty(department)){
		log.info("department is empty for"+ employeeNumber);
		employeeEntry.put("orgLevel3Description", "Invalid");	
		invalidStatus = true;
		}
		if(Util.isNullOrEmpty(email)){
		log.info("email is empty for"+ employeeNumber);
		employeeEntry.put("emailAddress", "Invalid");
		invalidStatus = true;
		}
		if(Util.isNullOrEmpty(division)){
		log.info("division is empty for"+ employeeNumber);
		employeeEntry.put("orgLevel2Description", "Invalid");
		invalidStatus = true;
		}
		
		if(invalidStatus){
		employeeEntry.put("employeeStatus", "Invalid");
		}

Any inputs on this ?

Appreciate your help :slight_smile:

Thank you ,
Saikumar

Hi @saikumar39,

i don’t see any straightforward issues with the rule code snippet you shared.

Can you try and confirm the following,

  1. Did we get any one of those info logs that you printed in the VA (ccg.log)? - You should see this is you have enabled debugging for your VA.
  2. Are you able to see the “Invalid” string value in any one of the fields (emailAddress
    , orgLevel3Description, orgLevel2Description)?

Do you see any of the 3 logs?

Invalid is updating for only employee status that too all users …No logs in ccg

Here my question is can we this validation in after operation rule ?

Honestly, I don’t see any reason not too.

WebServiceAfterOperationRule is there to perform something logic against the latest values of the fields after performing some operation.

To answer your question, Yes this seems like a valid use case WebServiceAfterOperationRule.

It depends on the purpose of validation you are doing. As the rule names suggest, they are run before or after the end system is updated.

As per my understanding, you utilize the before operation rule to modify the information used to update the end system and after operations rule to modify the response sent back to IdentityNow after updating the end system.

1 Like

Oh, this is interesting.

Can you add a couple more logs for me and try running it to see if there are any logs.

  1. Add a log statement on the first line of the Rule, which should execute irrespective of any logic that you have written below.
log.info("Info - Rule has been executed and logging works");
log.error("Error - Rule has been executed and logging works");
  1. Add a log printing invalidStatus variable just before the if condition,
log.info("Info - Value of invalidStatus before condition check"+ invalidStatus);
log.error("Error - Value of invalidStatus before condition check"+ invalidStatus);
if(invalidStatus){
	employeeEntry.put("employeeStatus", "Invalid");
}

If you don’t see the first log in ccg.log or error.log, I recommend you check the connector debugging configurations for more details you can check the following,

  1. The correct way to debug connector rules - Setup log4j configurations
  2. Logging Configurations are correct.
  3. Make sure debugging is enabled in the VA.

We have tried multiple way to print logs in CCG …Some how logs are not printing in CCG

In such cases I collect all the messages using StringBuilder and then throw an Exception at the end of the codes that contains the string. You can read the contents of the exception in UI.

I know this is a dirty way, but sometimes saves me time :smiley:

1 Like

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