Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

Service Portal: Supported design for conditional visibility and mandatory variables inside Variable

AkihiroY
Tera Contributor

Hello Community,

 

We are reviewing a Service Portal catalog design and would like guidance on a recommended and supported approach for handling conditional visibility and mandatory behavior.

 

Current situation:
- Catalog items use Variable Sets
- Some variables inside the Variable Set are initially hidden
- Based on user input, a Catalog UI Policy with conditions is used
- UI Policy Actions are used to control variables inside the Variable Set by setting:
   - Visible = true
   - Mandatory = true

 

This design worked for several years without issues. However, recently we started seeing instability in Service Portal.

 

Symptoms:
- A JavaScript error occurs in Service Portal, such as:
  "Cannot read properties of null (reading 'mandatory')" from sp_min.js
- When this error occurs, variables inside the Variable Set are not rendered at all
- As a result, the catalog item form does not display any variables and becomes unusable for end users
- This issue does not occur for all catalog items in Service Portal;
   it only affects specific catalog items with this design pattern.


When we contacted ServiceNow Support, they confirmed that this customization pattern (using UI Policy Actions to control visibility and mandatory state of variables inside Variable Sets in Service Portal) is considered unsupported.
However, no alternative or recommended design pattern was provided.

 

Questions:
1. What is the recommended and supported design pattern to implement:
    - Conditional visibility
    - Conditional mandatory behavior
    for variables inside Variable Sets in Service Portal?
2. Is using Catalog Client Scripts the preferred or supported approach in this scenario?
3. Are there any known KBs, documentation, or best practices that describe this limitation?
4. For large implementations with many existing catalog items using this pattern, what refactoring strategy would you recommend to improve stability and upgrade safety?

 

Any guidance from architects or MVPs would be greatly appreciated.

 

Thank you.

1 ACCEPTED SOLUTION

@AkihiroY 

So this is definitely platform upgrade issue

If you are sure this is working fine in other instance which is not on Zurich then share the details with ServiceNow on that ticket

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

View solution in original post

7 REPLIES 7

@Ankur Bawiskar 

Thanks Ankur, appreciate your input.

To answer your questions:
- The issue started about a week ago.
- We upgraded from Zurich Patch 6 to Patch 7 on April 18.
- There were no catalog or UI Policy changes around that time.
 

The issue only occurs in Service Portal and only for specific catalog items.
Classic UI works as expected, and the same design had been working for years.
 

Our analysis shows this is related to the evaluation timing/order of onLoad UI Policies
for variables inside Variable Sets.
A low-order UI Policy is evaluated before the variables are rendered in the DOM,
which triggers the sp_min.js error.
 

So while the timing aligns with the patch and suggests a platform behavior change,
it appears the patch exposed an evaluation-order–sensitive design pattern
rather than a general UI Policy issue.
 

We are addressing this via design refactoring to improve upgrade resilience.

@AkihiroY 

So this is definitely platform upgrade issue

If you are sure this is working fine in other instance which is not on Zurich then share the details with ServiceNow on that ticket

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

@Ankur Bawiskar 
Thank you, that was very helpful.
I will share the details with ServiceNow.