Client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 01:26 AM
Hi guys ,
State choice = Closed should be hidden from the form if State = new, for Change Tasks
for that I have written on load client script :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 04:02 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 02:20 AM - edited 06-25-2025 04:14 AM
Hi @tushar_ghadage,
Script needs correction to only remove when State is New. Also you would have to make OOB Closed choice inactive for this case as removeOption would remove it for future choices as well so we have to use addOption in script.
Use this script:
function onLoad() {
// First, always add the 'Closed' option to ensure it's present
g_form.addOption('state', '3', 'Closed');
// Then, if state is 'New', remove it
if (g_form.getValue('state') == '1') {
g_form.removeOption('state', '3');
}
}
Regards,
Ehab Pilloor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 03:05 AM
its hiding it for other option as well
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 03:41 AM
Hi @tushar_ghadage, did you try saving the record and check?
It will not show on new record, remember its onLoad script, save and try it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 03:22 AM
Hello @tushar_ghadage ,
To achieve this efficiently, you can use a onLoad client script.
function onLoad() {
var closedValue = '3'; // Value for 'Closed'
var closedLabel = 'Closed'; // Update if label is different
// Reusable function to update the visibility of 'Closed' option
function updateClosedOption(stateValue) {
if (stateValue === '1') { // '1' = New
g_form.removeOption('state', closedValue);
} else {
if (!g_form.getOption('state', closedValue)) {
g_form.addOption('state', closedValue, closedLabel);
}
}
}
// Run once on form load
updateClosedOption(g_form.getValue('state'));
// Watch for changes to the state field
g_form.watch('state', function(newValue) {
updateClosedOption(newValue);
});
}
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Reshma Kore.