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-27-2021 11:25 AM
Can you provide your script and a little more clarification. You say you want to set it to No on particular conditions but then in your onload script you are setting it to the default value of empty. If the default value is empty you should not have to set it onload.
Edit: Also when the form is loading is this variable visible?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2021 08:44 PM
I said catalog variable's default value is an empty. we are trying to set that value "No" using on load client script.
How to achieve this.
Yes variable is visible on form while form is loading
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2021 11:30 PM
Hi,
Please use the below steps to achieve your requirement:
function onLoad() {
//Type appropriate comment here, and begin script below
if (g_form.getValue('FIELDNAME') == '') { // Replace your Field Name here
g_form.setValue('variables.VapriableName', 'no'); // Replace Variable Name here and also the correct value of "no" which you can get from your Select Box Variable choice backend value
g_form.setReadOnly('variables.VariableName',true); // Replace your Varibale Name here/
}
}
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-27-2021 11:44 PM
Hi,
if (g_form.getValue('FIELDNAME') == '')
or if(g_form.getValue('variables.variable_name')=='')
which one needs to select , we want to set catalog variable value on requested item