Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

catalog task variable

ChittemV6340578
Kilo Contributor

I have created pc type variable in the catalog item, I made it should only visible in the catalog task once after the RITM has created, it showed as expected, but the thing is when I select pc type choice as secondary pc and saved the catalog task, after refreshing the page again it asking me select the pc type. I need help to fix this issue the pc type option should save with value.

 

 

3 REPLIES 3

Hemanth M
Tera Sage

Hi @ChittemV6340578 ,

 

Check if there are any catalog client scripts/UI policies clearing this value during form load....

 

how to verify quickly? - add a onLoad catalog client script on this catalog item(applies to catalog task checked) with this line

alert(g_form.getValue("pc_field_variable_name");

 

Hope it helps!

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025,2026

Rafael Batistot
Kilo Patron

Hi @ChittemV6340578 

 

Check the Question Choices related list and ensure all options have both Label and Value populated.

 

If you are using a UI Policy to display the variable on the Catalog Task, uncheck the Clear value if hidden checkbox.

 

If this response was helpful, please mark it as Helpful and, if applicable, as Correct.
This helps other users find accurate and useful information more easily

vaishali231
Kilo Sage

hey @ChittemV6340578 

This usually happens when the variable is being displayed correctly on the Catalog Task, but its value is not actually being persisted to the RITM variable record.

The important thing to remember is that Catalog variables belong to the RITM (sc_req_item). The Catalog Task only displays/uses those variables.

I would check the following:

Check the Catalog Client Scripts

Search the Catalog Item and Catalog Task for any onLoad or onChange script containing:

g_form.clearValue('pc_type');

or

g_form.setValue('pc_type', '');

or any logic that sets the variable again when the form loads.

If such logic exists, remove it or execute it only when required.

Check the Catalog UI Policies

Verify that the UI Policy used to make PC Type visible is only controlling:

Visible = true

and is not clearing or resetting the variable value.

Also check whether the UI Policy is running on load and changing the field value.

Verify the variable is actually stored

After selecting Secondary PC and saving the Catalog Task, check the related RITM.

The value should be stored in the catalog variable records associated with that RITM.

If the value exists on the RITM but disappears only from the Catalog Task after refresh, then the issue is most likely with how the variable is being displayed on the task.

Check Business Rules / Flow Designer

If the value is completely removed after refresh, check whether any Business Rule, Flow, Workflow, or Script Include is updating the RITM or catalog variable records.

Look especially for scripts modifying:

sc_item_option

sc_item_option_mtom

One more important point

If you are setting the variable through a Catalog Task client script, make sure you are referencing the variable correctly:

g_form.setValue('variables.pc_type', 'secondary_pc');

However, if the user is manually selecting the value, you normally should not need to set it again with script. ServiceNow should persist the selected variable value.

 

*************************************************************************************************************************************

If this response helps, please mark it as Accept as Solution and Helpful.

Doing so helps others in the community and encourages me to keep contributing.

Regards

Vaishali Singh

Servicenow Developer
Linkedin - https://www.linkedin.com/in/vaishali-singh-2273361bb