How to set default value of variable in catalog item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-17-2020 08:52 PM
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. .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-17-2020 09:16 PM
Hi Priya,
You need to pass the right choice value of the choice record instead of passing in the sys_id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-17-2020 09:37 PM
This does not set the value onload of the form.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-17-2020 09:25 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-17-2020 09:25 PM
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
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader