Client Script not clearing out field if previous field is certain option
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 07:39 AM
I'm trying to create a client script for a catalogue item if certain values appear in the previous field:
In the above example, if the 'Record Retirement Method' field is set to 'no data', then I want the 'Record Retirement Method Updated' field to be cleared out. I've written the below onChange client script to get other fields working the same way:
function onChange() {
//Type appropriate comment here, and begin script below
if (g_form.getValue('support_cbp') == '-- no data --') {
g_form.clearValue('new_support_cbp');
}
if(g_form.getValue('external_customer_detriment') == '-- no data --') {
g_form.clearValue('new_external_customer_detriment');
}
if(g_form.getValue('ledger_regulatory_or_planning_usage') == '-- no data --') {
g_form.clearValue('new_ledger_regulatory_or_planning_usage');
}
if(g_form.getValue('staff_volume_using') == '-- no data --') {
g_form.clearValue('staff_volume_using');
}
if(g_form.getValue('staff_volume_supporting') == '-- no data --') {
g_form.clearValue('new_staff_volume_supporting');
}
if(g_form.getValue('registration_reason') == '-- no data --') {
g_form.clearValue('new_registration_reason');
}
if(g_form.getValue('record_retirement_method') == 'no data') {
g_form.clearValue('new_record_retirement_method');
}
}
If somebody could explain where I'm going wrong with my client script, that would be much appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 11:44 AM
So obviously, you want to make sure both of the variable names are exactly correct - case and space-sensitive, and that the value for this selection is exactly 'no data'. You could even add an alert line to cover most of this, before or after this if statement to see what the value of this variable is when the script runs. When you do that I suspect it will be blank if this is running onChange of a different variable and Record Retirement Method is getting set by a different script. If this is the case, pull this if block out of this script and put it in its own onChange script when record_retirement_method changes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 12:11 AM
Hi @Brad Bowman This is the list of options:
So I'm taking the label from the 'Value' column and applying that to my client script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 12:26 AM
Hello, i dont think the choice value will return "--no data--", it must be "no data". Can you keep a alert in your client script to check what value the script is returning like below?
var getSupportcbp = g_form.getValue('support_cbp');
alert("choice value"+getSupportcbp ); // check here whether you get '-- no data --' or 'no data'
if (g_form.getValue('support_cbp') == '-- no data --') {
g_form.clearValue('new_support_cbp');
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 07:28 AM
It's best to avoid spaces and extraneous special characters for values as a general rule. In any event, this choice is inactive, and your script is using 'no data' for record_retirement_method, so what is the value of record_retirement_method when euc changes?