How to hide all the variables on RITM and task form

Joshuu
Kilo Sage

Hello All,

I need to hide all the variables on RITM and catalog task form for one specific catalog item.

Please help.

Thank you,

Priya.

21 REPLIES 21

Hi,

Please uncheck Applies on a Catalog Item view checkbox

try to check in alert what comes

function onLoad() {

alert(g_scratchpad.Variables);
   
   if(g_scratchpad.Variables != ''){
      var emptyVars = g_scratchpad.Variables.split(',');
      for(i = 0; i < emptyVars.length; i++){
         g_form.setDisplay(emptyVars[i], false);
      }
   }
}

Regards
Ankur

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

Hello Ankur,

It is working now. I have modified the BR's to display.

But i have few more doubts as below.

Now I am not able to see the variables on catalog form too.

And also can we exclude for one particular group here. Like apart from that group noone else should see those variables.

Is that possible?

Please help.

Thank you,

Priya.

@priyarao 

Please find responses below

1) Now I am not able to see the variables on catalog form too.

This BR and onLoad is not the reason for hiding those variables; as the client script won't run on Catalog Item View.

Please ensure that checkbox is false for Applies to Catalog Item view

Also check any other client script or UI policy is hiding the variables

2) Regarding group you can do this

Both the BR Script:

var variables = current.variables.getElements();
var arr = [];
for (var i=0;i<variables.length;i++) {
        var variableName = variables[i].getQuestion().getName();
        arr.push(variableName.toString());
}

g_scratchpad.Variables = arr.toString();

g_scratchpad.isMemberOf = gs.getUser().isMemberOf('Group ABC');

Client Script:

function onLoad() {

   // if logged in user is not member of that group then hide
   if(g_scratchpad.Variables != '' && g_scratchpad.isMemberOf.toString() == 'false'){
      var emptyVars = g_scratchpad.Variables.split(',');
      for(i = 0; i < emptyVars.length; i++){
         g_form.setDisplay(emptyVars[i], false);
      }
   }
}

Regards
Ankur

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

@priyarao 

Glad to know that it worked.

Please mark my response as correct and helpful to close the thread and to benefits others from this.

Regards
Ankur

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

@priyarao 

Glad to know that it worked.

Please mark my response as correct and helpful to close the thread and to benefits others from this.

Regards
Ankur

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