Catalog form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2024 02:42 AM
Two fields : Select Box : action : two choices (Extend , No extend).
: Select Box :visible : two choices (Contract , No contract).
If the user action field select (extend choice ) then visible field "No contract" should be visible and remaning choice hide on the form level.
using calalog client script not working.
Any idea help me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2024 02:51 AM - edited 07-29-2024 02:58 AM
Hi @Ram012 ,
You can do this by using onChange catalog client script. and use g_form.removeOptions and g_form.addOption functions to remove and add condition dynamically.
You can use this logic, feel free to customize it and correct the field/option names:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
// Remove all options from the 'visible' field
g_form.clearOptions('visible');
// Add options based on the value of 'action'
if (newValue == 'extend') {
g_form.addOption('visible', 'no contract', 'No Contract');
} else {
g_form.addOption('visible', 'contract', 'Contract');
g_form.addOption('visible', 'no contract', 'No Contract');
}
}
Thanks.
Hope it helps.
Mark it helpful and Accept Solution if it helped.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2024 03:05 AM
Hello @Ram012 ,
Show the client script you wrote..
try with this client script --
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) return;
var actionValue = g_form.getValue('action'); // Get the value of the 'action' field
// Determine the visibility of options in the 'visible' field
if (actionValue === 'extend') {
g_form.clearOptions('visible'); // Show only 'No Contract' option and hide the rest
g_form.addOption('visible', 'No contract', 'No contract');
} else {
// Show all options
g_form.clearOptions('visible');
g_form.addOption('visible', 'Contract', 'Contract');
g_form.addOption('visible', 'No contract', 'No contract');
}
}
If you found my response helpful, please consider marking it as "Helpful" or "Accept Solution." Thank you!