cancel
Showing results for 
Search instead for 
Did you mean: 

how can i hide a control (objectCell) using a rule

juanforero5
Participant
0 Kudos
651

Right now I have an application that in the main menu has several Objectcells for the different sections of it.The problem is that I need a control to be automatically hidden when the application starts if the user is of MX nationality and I am using the following rule.

I simply check the service for the nationality of the user who is logged in at the moment and if it is MX it returns false and if it is CO it returns true, I am assigning this rule to the (visible) property of the objectcell but it does not work, does anyone know how it could be done?

export default function RuleMainMexico

(clientAPI) {
	var pernr = clientAPI.evaluateTargetPath("#Application/#ClientData/#Property:UserId");
	return clientAPI.read('/SkyCM_V2/Services/SkyCM_V2.service', 'VENDORINFO', [], `$filter=PERNR_SCP eq '${pernr}'`).then((results) => {

		if (results && results.length > 0) {
			let prod = results.getItem(0);
			var natio = prod.NATIO;
			if (natio == "MX") {
			
				return false;
			} else if (natio=="CO")  {
				
				return true;
			}
		} else {
			return true
		}
	});

}

Accepted Solutions (0)

Answers (0)