Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Hide variables from Portal

Cat
Mega Guru

Hi all,

 

I'm trying to do something that seems simple, but for the life of me, I can't get it to work.

 

I have a couple of variables that I have only visible in the Catalog Task and it is hidden in the Request item and Portal.

When the variable is filled in in the sctask, it doesn't appear in the request item. However, it appears on the portal. I'm using a Catalog UI policy to make it only visible in the sctask. I also created a Catalog Client Script to hide the variable on the portal using a g_form.SetVisible false

 

I feel like I've done everything I can, but as soon as the variable is filled in, it shows up on the portal!

 

Does anyone have any ideas of what I am missing?

 

Thanks for any help!

8 REPLIES 8

Nawal Singh
Tera Guru

Hi @Cat ,

your issue is variable is not visible in RITM , but it should as per my understanding.

client script that you are using to hide variables- check whether it's works for Requested item or not or only works for SC task.

 

if it's applied in RITM or Sc task or portal page then it should work all there.

 

If you found my response helpful, please mark it as helpful and accept it as the solution.

Thank you
Nawal Singh

MaxMixali
Tera Guru


Hi you can try to create Container Variable, hopping that can help

Navigate to: Service Catalog > Variable SetsClick: NewConfiguration:

Name: SCTASK Only Variables
Type: Multiple Row
Internal name: sctask_only_vars
Order: 100
Step 2: Move Your Variables to This Set
Find your variables that should only show in SCTASK
Edit each variable
Change Variable Set to: SCTASK Only Variables


Step 3: Add Conditional Display LogicOn the Variable Set

record:Conditions tab:Create conditions that determine when the set should display:Applies
to: Catalog Task [sc_task]Or use a condition script:Condition script:

// Show variable set only on Catalog Tasks

answer = (current.getTableName() == 'sc_task');Step 4: Configure Variable Set AssociationIn your Catalog Item:

Go to Variables related list
Add the Variable Set
Configure Visible conditions
Variable Set inclusion condition:

// Only include this variable set for SCTASK context

Javascript:

(function() {
// Check if we're on a catalog task
if (typeof current != 'undefined' && current.getTableName() == 'sc_task') {
return true;
}
return false;
})();

 

Ankur Bawiskar
Tera Patron
Tera Patron

@Cat 

what do you mean by Shows up on portal?

where are you referring this? share screenshots.

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

The variable is visible to the client on the Service Portal