We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Variable to be hidden in RITM

chinagudish
Giga Contributor

the variable 'by submit' created for the task when select option Type A is selected has to be visible and mandatory but not when TYPE B . At the same time when type B is selected and task is created for it along with the RITM then the variable 'by submit' should not be visible over the RITM of the type B selection. How to achieve this?

4 REPLIES 4

Tanushree Maiti
Tera Patron

Hi @chinagudish 

 

Try this:

 

 

  1. Navigate to your Catalog Item and scroll to the Catalog UI Policies related list > Click New
  • fill in the following:
    • Applies to: A Catalog Task [sc_task]
    • Applies on Catalog Item view: Leave unchecked.
    • Conditions: Type is Type A.
  • Save the UI Policy.
  • Scroll to the Catalog UI Policy Actions related list and click New:
    • Variable name: by_submit
    • Visible: True
    • Mandatory: True

 

  1. Navigate to your Catalog Item and scroll to the Catalog UI Policies related list > Click New
  • fill in the following:
    • Applies to: A Catalog Task [sc_task] .
    • Applies on Catalog Item view: Leave unchecked.
    • Conditions: Type is Type B.
  • Save the UI Policy.
  • Scroll to the Catalog UI Policy Actions related list and click New:
    • Variable name: by_submit
    • Visible: False
    • Mandatory: False

 

 

3) Hide the Variable on the RITM

On your Catalog Item> Catalog Client Scripts related list > click New.

Configure the script:

Type: OnLoad

Applies on Requested Items: True

 

function onLoad() {

   var itemType = g_form.getValue('type');  // replace your actual variable name

   if (itemType == 'type_b')   // // replace your actual variable Value

 {

       g_form.setDisplay('by_submit', false);

   }

}

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

pr8172510
Kilo Sage

Hi @chinagudish,

You can achieve this without customization by using separate Catalog UI Policies.

  • Catalog Task (sc_task)

    • Create a Catalog UI Policy that applies to Catalog Task.

    • Condition: Type = Type A

      • by_submit → Visible = true, Mandatory = true

    • Create another policy for Type = Type B

      • by_submit → Visible = false, Mandatory = false

  • Requested Item (sc_req_item)

    • Create another Catalog UI Policy with Applies on Requested Items enabled.

    • Condition: Type = Type B

    • Add a Catalog UI Policy Action:

      • by_submit → Visible = false, Mandatory = false


This keeps the behavior consistent on both the Catalog Task and the RITM without relying on client-side scripting.

 

Ankur Bawiskar
Tera Patron

@chinagudish 

so what script did you start with and where are you stuck?

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

I tried catalog client script on Load and On change ,it did not work . Ieven followed the above approaches but nothing seems to be working.