Make a field not mandatory

Gemma4
Mega Sage

Hi Everyone,

I have a requirement to make fields mandatory on the ritm level but only mandatory for a group of users completing the form? Below are the details of the process

The variables are hidden on the catalog item. 

If the manager determines additional information is needed then the variables are required by a yes/no ui policy

The problem is the manager doesn't need to complete the form, so I need to exclude her and others from seeing them as required. 

I realize the best way to achieve this is probably with a UIPolicy but I'm struggling on how to exclude the manager/group from seeing the variables as required. 

Below is the script I have so far but not sure if there is a better way to do this or if its possible?

 

function onSubmit() {

 

    //Type appropriate comment here, and begin script below

 

    g_form.setMandatory('field_name',false);

 

}

 

Thanks so much for any feedback you have!

27 REPLIES 27

Samaksh Wani
Giga Sage
Giga Sage

Hello @Gemma4 

 

 

 

function onLoad() {
if(gs.getUser.isMemberOf('sys_id_of_group'){
    g_form.setMandatory('field_name',true);
}
if(gs.getUser.isMemberOf('sys_id_of_manager'))
  g_form.setMandatory('field_name',false);
}

 

 

 

 

and Most Probably use should use it on onLoad() Client Script.

 

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Samaksh

 

Hi @Gemma4 ,

 

Since you need to check the "group" , "members" . This information is from server side, So you need to use 'gs' User object "(gs.getUser().isMemberOf(Group_Name)" .

1. write a function in client callable script include to check the group of user.
2. write an OnLoad client script and make Ajax call , based of response from server you can hide or show  the respective fields.

@Samaksh Wani gs (glidesystem) don't work on client side.


Hope it helps and please mark helpful if it solves the issue.

Thanks,

Pooja Singh

HI @Samaksh Wani 

Thank you for the feedback but I think there may be a typo. I'm receiving a parsing error. Any ideas? 

script parsing error.png

Hello @Gemma4 

 

Use this Script:-

 

 

 

 

function onLoad() {
if(gs.getUser().isMemberOf('sys_id_of_group')){
    g_form.setMandatory('field_name',true);
}
if(gs.getUser().isMemberOf('sys_id_of_manager')){
  g_form.setMandatory('field_name',false);
}
}

 

 

 

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Samaksh