Onload Client Script to make Variable mandatory is getting clear on load of form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2024 10:36 AM - edited 09-29-2024 10:39 AM
Hi All,
I have written Onload Client Script to make variable "is_this_it_sponsored" within the variable editor mandatory based on catalog task short description. When I enter the value and close the task. Then after the form reloads the value is getting clear and again showing mandatory .Can you all please help me with this.
function onLoad() {
if (g_form.getValue('short_description') == 'Review request details') {
g_form.setMandatory('variables.is_this_it_sponsored', true);
} else if (g_form.getValue('short_description') == 'Conduct Technical evaluation' ||
g_form.getValue('short_description') == 'Review integration request & schedule discovery meeting') {
g_form.setMandatory('variables.operational_impact', true);
g_form.setMandatory('variables.is_this_it_sponsored', false);
g_form.setDisplay('variables.is_this_it_sponsored', false);
} else if (g_form.getValue('short_description') == 'Conduct AI review' || g_form.getValue('short_description') == 'Conduct Cloud review' ||
g_form.getValue('short_description') == 'Conduct Infosec review') {
g_form.setDisplay('variables.operational_impact', true);
g_form.setReadOnly('variables.operational_impact', true);
} else {
g_form.setMandatory('variables.operational_impact', false);
g_form.setDisplay('variables.operational_impact', false);
g_form.setMandatory('variables.is_this_it_sponsored', false);
g_form.setDisplay('variables.is_this_it_sponsored', false);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2024 11:30 AM
Try temporarily inactivating this script to see if the behavior is the same. It sounds like you have another Catalog Client Script or UI Policy affecting this variable. Since it's after after an update, it could also be a Client Script, UI Policy, or Business Rule on the sc_task table. In the script, you don't need variables. in g_form methods. It's probably not hurting anything as long as it is otherwise working, but it is unnecessary.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 09:42 AM
Hi Brad,
My requirement is to make some variables mandatory & visible when catalog task short description is something something .
When I am writing Onload client script to make mandatory and display true based on short description. After saving the from its clearing the value from the form
When I am writing Onload client script to make
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 09:46 AM
I was following that, but the cause may be a different script is why I suggested trying to make the variable visible if it's not already, then trying the same test steps with this script inactive to see if the same behaviour is observed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 09:54 AM
Hi Brad ,
I deactivated the script its working fine as expected but the hide and show of variables based on short description is not working all the variables are visible on all the catalog task form