Is it possible to set default_value from the client script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2022 01:50 AM
I create a Custom variable on the Catalog item and Used the widget there like mentioned in this article: https://community.servicenow.com/community?id=community_article&sys_id=659ff21cdb30105013b5fb2439961...
One question is it possible to set the same default value data from the client script?
I want to set the dynamic default value.
My default value has encoded query and when the type field changes, the default value should change accordingly.
Ex: My Default value
{
"widget": "table_values",
"title":"Table values",
"maximum_entries": 1,
"table": "custom_table",
"encoded_query": "active=true^ORDERBYorder",
"dropdown_title": "name",
"dropdown_description": "description",
"dropdown_image": "image",
}
Ex: If the Top field (type) changes I want to change the encoded query for that reason I want to set the default value from the catalog client script but no luck.
"encoded_query": "active=true^ORDERBYorder^type=individual",
I tried onLoad, and OnChange client scripts with setValue but not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2022 03:19 AM
Hi ,
There is no way to set default values via client script, however you can use on-load client script to set values when the form load, to an end user that will look like a default value.
Please mark this correct and helpful if it helps.
Regards!
Uma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2022 03:29 AM
Hi,
so based on some variable present on catalog item form you need to set some default value in widget variable?
share some screenshots
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2022 02:34 AM
Hi Ankur,
Thanks for the replay please find the details below:
Record producer portal view:
Record producer fulfiller:
I tried to set the default value from the client script but looks like it is not possible!
With client script, it's possible to set values but I don't want to set values, I want to initialize the dropdown with new options.
When the Type changes, the default value should also change.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2022 05:30 AM
Hi,
I doubt for this
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader