Is it possible to set default_value from the client script?

Mr world wide
Mega Guru

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

5 REPLIES 5

umaaggarwal
Giga Guru

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

Ankur Bawiskar
Tera Patron
Tera Patron

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

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

Hi Ankur,
Thanks for the replay please find the details below:

 

Record producer portal view:
find_real_file.png

 

Record producer fulfiller:

find_real_file.png

find_real_file.png



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.

 

Hi,

I doubt for this

Regards
Ankur

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