Using UI Builder to Hide Component in SOW not Working

tiguin2798
Tera Guru

Good Afternoon,

 

I am attempting to hide the 'Main Tab' component in Service Operations Workspace using UI builder to hide all record details (Overview, form sections, activity stream, etc.) However, I do not wish to hide this for everyone on every form. I want to hide specific incidents based on the subcategory, and only if a user has a specific role.

 

I have tried to achieve this functionality with different variations on the two scripts below, but neither is working as my test user. I'm doing this through 'hide component' in UI builder. I tested hiding the component overall and that works, but does not work with a script. I'm fairly new to javascript as well. If someone could remediate my script or tell me if I'm missing something with the configuration it would be greatly appreciated!

I did also notice there is 'client state' configuration which allows me to configure with 'bind data' or adding script includes so not sure if it is needing something there?


/**
  *  {params} params
  *  {api} params.api
  *  {TransformApiHelpers} params.helpers
  */
function evaluateProperty({api, helpers}) {
  var currentTable = incident;
  var validSubcategories = ['test 1', 'test 2', 'test 3', 'test 4', 'test 5', 'test 6'];

  if (currentTable === 'incident') {
    let user_roles = api.context.session.user.roles;
    let visibility_condition 
      = user_roles.includes("CAB_test_role");
      var isValidSubcategory = validSubcategories.indexOf(subcategory) > -1;
    return 'true';
    } else {
    }
}
/**
  * @Param {params} params
  * @Param {api} params.api
  * @Param {TransformApiHelpers} params.helpers
  */
function evaluateProperty({api, helpers}) {
  let user_roles = api.context.session.user.roles;
  let visibility_condition 
      = user_roles.includes("THE USER'S ROLE THAT SHOULD NOT SEE THE ELEMENT");
	return visibility_condition;
}
0 REPLIES 0