How to set field(catalog variable) value on requested item using client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2021 08:18 AM
Hi All,
We have one catalog variable type (select box). available choices are yes/no
default value is empty.
we are trying for particular condition , field value should be set to "No" and read only on requested item label.
so we are using on load client script but g_form.setValue('field_name',''); is not working.
How to achieve this.
Thanks in advance,
Sayan Ghosh
- Labels:
-
Request Management
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2021 01:54 AM
Hi,
unfortunately this code isn't working.
g_form.clearvalue isn't clear the value.
its showing default value no
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2021 02:11 AM
Hi,
The script shared above works for me:
Output:
Can you share your Script here and also a screenshot of your Variable which you have configured to get you to a solution.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2021 09:04 AM
After reading though this post can you clarify what you are trying to do. If you want it set to No when the form loads for the end user this needs to be a catalog client script. In the catalog client script you can just refence the variable name without "variables." in front of it. Since it is an onload script there is not need to check if the variable is already set to blank since that is the default value.
Something like this should work.
function onLoad() {
//Type appropriate comment here, and begin script below
g_form.setValue('variable Name', 'no'); // Replace Variable Name with your variable name and ensue that no is the correct backend value
g_form.setReadOnly('variable Name', true); // Replace your Varibale Name with your variables name
}
Edit: Another thought: Since you are using an onLoad client script why not may the default value "no" and use a UI Policy to make it read only except for the conditions where you want them to be able to change it.