Passing Property Value dynamically in ACL

ABC6
Tera Contributor

How to use property that have multiple value in ACl,
i have created one property with string type and in value put Property1,Property 2

in an ACl write the below script

var valueProperty = gs.getProperty('property.write');
if (gs.hasRole('user_adv_admin')) {
    answer = true;
} else if (gs.hasRole('itil') && valueProperty == current.getDisplayValue('u_property')) {
    gs.addInfoMessage(valueProperty+"Table");
    answer = false;
} else if (gs.hasRole('itil') && valueProperty != current.getDisplayValue('u_property')) {
    answer = true;
}
 
Please let me know if i am doing the wrong way to pull value from property dynamically or what should be the correct way to pass property here if property has multiple value
1 ACCEPTED SOLUTION

Sid_Takali
Kilo Patron
Kilo Patron

Hi @ABC6 Try this

var valueProperty = gs.getProperty('property.write');
var propertyValues = valueProperty ? valueProperty.split(',') : [];

if (gs.hasRole('user_adv_admin')) {
    answer = true;
} else if (gs.hasRole('itil')) {
    var currentPropertyValue = current.getDisplayValue('u_property');

    if (propertyValues.indexOf(currentPropertyValue) !== -1) {
        gs.addInfoMessage(currentPropertyValue + " Table");
        answer = false;
    } else {
        answer = true;
    }
}

View solution in original post

1 REPLY 1

Sid_Takali
Kilo Patron
Kilo Patron

Hi @ABC6 Try this

var valueProperty = gs.getProperty('property.write');
var propertyValues = valueProperty ? valueProperty.split(',') : [];

if (gs.hasRole('user_adv_admin')) {
    answer = true;
} else if (gs.hasRole('itil')) {
    var currentPropertyValue = current.getDisplayValue('u_property');

    if (propertyValues.indexOf(currentPropertyValue) !== -1) {
        gs.addInfoMessage(currentPropertyValue + " Table");
        answer = false;
    } else {
        answer = true;
    }
}