How we can hide the CI asset tab on the for users who dont have a customer role

kurella swamy
Tera Contributor

How we can hide the CI asset data tab on the "cmdb_ci_computer" for users who don't have a customer role like "x_cmdb_write"

kurellaswamy_0-1745844500247.png

Tried below script but it is not working 

function onLoad() {
   
   if(g_user.hasRole('x_cmdb_ci_customer_write')){
    g_form.setSectionDisplay('CI asset data', true);
   }else{
    g_form.setSectionDisplay('CI asset data',false);
   }
   
}

Thanks in advance
4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@kurella swamy 

use this -> section name should be in lower case and separated with _

function onLoad() {
   
   if(g_user.hasRoleExactly('x_cmdb_ci_customer_write')){
    g_form.setSectionDisplay('ci_asset_data', true);
   }else{
    g_form.setSectionDisplay('ci_asset_data',false);
   }
   
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@kurella swamy 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

kurella swamy
Tera Contributor

@Ankur Bawiskar 
Tried with above script but it is not working

 

@kurella swamy 

it should work fine provided the role name and section name is correct

share what debugging did you do?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader