How to set default value of variable in catalog item.

Priya75
Tera Contributor

HI All,

I have a catalog item with variable( sub-state) and when we submit the catalog a new record is created on the hardware table. I have created a onload catalog catalog client script, which sets the value of sub-state to available. when i open this record in  the hardware table, the new choice is getting created rather than the old value being used. i have used the sys_is of the record in catalog script. .

11 REPLIES 11

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Priya,

You need to pass the right choice value of the choice record instead of passing in the sys_id.

This does not set the value onload of the form.

Apeksha Joshi
Kilo Guru

Hi Priya ,

 

you need to pass the exact backend value of the 'Available' Choice of the sub-state field of hardware table .

while setting the substate through client script set the exact backend value of option 'available' of Hardware table. 

 

for eg .

you might be using g_form.setValue('sub_state','Available');

this will create new choice in that field on Hardware table , insted you need to set the exact backend value of 'availabe' option of Hardware table , lets assume it is '2' :

g_form.serValue('sub_state',2);

 

 

If my reply helps you at all, I’d really appreciate it if you click the Helpful button and if my reply is the answer you were looking for, it would be awesome if you could click both the Helpful and Accepted Solution buttons!

Regards,

Apeksha
 

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Do you want to set default value to variable in catalog item?

If yes then you need to open the variable and set the default value in the variable section

Regarding your question of new choice please share the script

Regards
Ankur

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