when I select the none option in the field then another field also will be the same like "'--none--"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 03:29 AM
I have taken two fields which are "City" and "Pin code". both the city and pin code fields already include "-- None --", and want to set the pin code field to "-- None --" when "None" is selected in the city field,
I have written the client script for When the choice value is selected in the City field then adding the options Here Working properly (added options when i select the city choice))
Here i went back it means i select none, but it still showing pin code valueon the Choices to the Pin code field.
options are added to the "Pin code" field properly but,
when the 'none' option is selected it shouldn't clear the existing value.
it shows the existing value even though I select the "none" option in the "city" field.
Note : on the Service Portal,
I tried the below code:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 03:36 AM
Hi @prasad24 you can do like this
if(newValue == '')
{
g_form.clearValue('variablename');
}
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 03:45 AM
Hi @prasad24
I haven't tried it but can you please try this and let me know if this works
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue == 'Hyd') {
g_form.clearOptions('u_pin_code');
g_form.addOption('u_pin_code', '100001', '100001');
g_form.addOption('u_pin_code', '100002', '100002');
g_form.addOption('u_pin_code', '100003', '100003');
} else if (newValue == 'Bangalore') {
g_form.clearOptions('u_pin_code');
g_form.addOption('u_pin_code', '200001', '200001');
g_form.addOption('u_pin_code', '200002', '200002');
g_form.addOption('u_pin_code', '200003', '200003');
} else if (newValue == 'Chennai') {
g_form.clearOptions('u_pin_code');
g_form.addOption('u_pin_code', '300001', '300001');
g_form.addOption('u_pin_code', '300002', '300002');
g_form.addOption('u_pin_code', '300003', '300003');
} else if (newValue == '') {
g_form.setValue('u_pin_code', '');
}
}
Mark Correct and Helpful if it helps.
***Mark Correct or Helpful if it helps.***
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 04:07 AM
Hello,
Try using g_form.clearValue('u_pin_code');
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024 10:25 PM
Hi @Yousaf
It's not working
I'm getting the same issue