client script

Shreshta_happy
Tera Contributor

Hi ,

I have

3 different assigned groups(X,Y,Z) on task form

1 field as sub status on task form

(if  assigned group to X) then members of Y and Z should not be able to edit the substatus field on the task form 

(if  assigned group to Y) then members of X and Z should not be able to edit the substatus field on the task form 

(if  assigned group to Z) then members of X and Y should not be able to edit the substatus field on the task form 

 

I want the above in a single if condition, please help

 

 

 

 

4 REPLIES 4

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Shreshta_happy ,

 

The logic for this would be if the logged in User is member of the assigned group then g_form.setReadOnly('substatus',false);

else 

g_form.setReadOnly('substatus',true);

 

for validation u need to write a client script where u need to pass assigned group as parameter to script include using Glide Ajax.

Check the logic in the script include where logged in user is member or not of the assigned group.

Return true or false from script include & based upon answer received make the substatus field read only.

 

Thanks,

Danish

 

Samaksh Wani
Giga Sage
Giga Sage
(function executeRule(current, previous /*null when async*/ ) {

    g_scratchpad.grpx = (gs.getUser().isMemberOf("sys_id_of_x_grp"));
    g_scratchpad.grpy = (gs.getUser().isMemberOf("sys_id_of_y_grp"));
    g_scratchpad.grpz = (gs.getUser().isMemberOf("sys_id_of_z_grp"));
    
})(current, previous);

 

OnLoad Client Script :-

 

function onLoad(){

var grp = g_form.getValue('assignment_group');
if(grp=='sys_id_of_x_group'){
if(g_scratchpad.grpx != true){
g_form.setReadOnly('sub_status', true);
}
}
if(grp=='sys_id_of_y_group'){
if(g_scratchpad.grpy != true){
g_form.setReadOnly('sub_status', true);
}
}
if(grp=='sys_id_of_z_group'){
if(g_scratchpad.grpz != true){
g_form.setReadOnly('sub_status', true);
}
}

}

 

 

Plz mark my solution as Accept, If you find it helpful.

 

Regards,

Samaksh

Samaksh Wani
Giga Sage
Giga Sage

Hello @Shreshta_happy 

 

If you find my response helpful, plz mark it accepted.

 

Regards,

Samaksh

StaceyHartzler
Kilo Contributor

You can achieve this with a client script. Use the logic provided by Danish Bhairag2 for setting read-only status based on assigned groups. Samaksh Wani's script illustrates the implementation.