In this article you will learn about how to apply expressions in a conditionIf and groovy execution type.
Suppose you want to hide a table employee_details belongs to SampleTravelData Metadata from a user/role/organization, then you are required to provide the conditional statement.
Now, Let us understand through cases
Case1 : Hide employee_details table from the user when username is ‘john‘
- conditionIf :
${user}.name eq 'john'
- groovy script :
import com.helical.efw.efwcomponents.metadata.GroovyUsersSession;
def evalCondition(){
boolean isUserJhon = GroovyUsersSession.evaluateCondition('${user}.name eq "john"');
return isUserJhon;
}
Case 2 : Hide employee_details table from the user when username is ‘jenny’ and organization is ‘Infinity’
- conditionIf :
${user}.name eq ‘jenny‘ and ${org}.name eq ‘Infinity‘
- groovy script :
import com.helical.efw.efwcomponents.metadata.GroovyUsersSession;
def evalCondition(){
boolean isUserJenny = GroovyUsersSession.evaluateCondition('${user}.name eq "jenny"');
boolean isOrgInfiinity = GroovyUsersSession.evaluateCondition('${org}.name eq "Infinity"');
return isUserJenny && isOrgInfiinity;
}
Case3 : Hide employee_details table from the user when user has role ROLE_USER
- conditionIf :
check(“${role}”,”ROLE_USER”)
- groovy :
import com.helical.efw.efwcomponents.metadata.GroovyUsersSession;
def evalCondition(){
def userRole = GroovyUsersSession.getValue('${role}.name');
if(userRole.contains('ROLE_USER'){
return true
}
else
{
return false
}
}
One Reply to “Application of ConditionIf and Groovy Expression Type”