The CreatorCon Call for Content is officially open! Get started here.

Make Variables visible and mandatory after submit for people with specific roles

kailashthiyagar
Kilo Guru

I m working on a service catalog item. I have a list of variables which i need to make visible and mandatory on submit for people with certain roles. How to do that using UI policy..

In the UI policy, i selected, "Applies on Requested Items" and removed "Applies on Item Catalog view" checkbox.

Added the UI action as "Visible" and "Mandatory" true

But it doesnt help

1 ACCEPTED SOLUTION

I have done the changes. it is wrkg fine now.



Note: kindly change the password. Someone might mis use it.


Regards
Harish

View solution in original post

17 REPLIES 17

Harish KM
Kilo Patron
Kilo Patron

you should write onload client script



function onLoad() {


  if(!g_form.isNewRecord() && g_user.hasRole('rolename'))


{


  g_form.setDisplay('fieldname',false);


  }


  else{


  g_form.setDisplay('fieldname',true);


  }



}


Regards
Harish

Alikutty A
Tera Sage

Hi,



Since you require these validations on requested item, make the applies flag set for requested item on an onLoad catalog client script and add this code



function onLoad() {


  if(g_user.hasRole('rolename')){


          g_form.setDisplay('fieldname',true);


          g_form.setMandatory('fieldname',true);


  }else{


          g_form.setDisplay('fieldname',false);


          g_form.setMandatory('fieldname',false);


  }


}



Thanks


Please Hit like, Helpful or Correct depending on the impact of the response


amlanpal
Kilo Sage

Hi Kailash,



Please write an onLoad Catalog Client Script and check only 'Applies on Requested Items' & 'Applies on Catalog Tasks'. Please write the script as of below:



if (g_user.hasRole('role_name')){


g_form.setVisible('variable_name', true);


g_form.setMandatory('variable_name', true);


}


else {


g_form.setMandatory('variable_name', false);


g_form.setVisible('variable_name', false);


}



I hope this helps.Please mark correct/helpful based on impact


harishkumar alikuttyka amlanpal



I tried adding the below script for time being since i havent created role yet, But the variable appears in my catalog item view itself.. i dont want the requestor to see this variable in the form while they make request.



if(g_form.isNewRecord())


  {


  g_form.setDisplay('code_is_consistently_formatted',false);


  }


  else{


  g_form.setDisplay('code_is_consistently_formatted',true);


  }