Make check box unvisible using onChange client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2024 08:58 AM
Hey
I created a check box on incident form in SOW called u_false_transfer.
I need this check box to be visible only if Assignment group type is not 'itil' .
I tried to use UI POLICIES but it workes only after saving the record.
Now I want to write ONchange client script.
The code:
Can someone please help me fix it
Thanks, Shir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2024 09:07 AM
Hello @Shir Sharvit ,
Please give a try to the script below and let me know how it works for you.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (control == 'assignment_group') {
var assignmentGroupType = g_form.getDisplayValue('assignment_group.type');
if (assignmentGroupType !== 'itil') {
g_form.setDisplay('u_false_transfer', true); // Show the checkbox
} else {
g_form.setDisplay('u_false_transfer', false); // Hide the checkbox
g_form.setValue('u_false_transfer', false);
}
}
}
Let me know your views on this and Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2024 09:22 AM
This code not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2024 09:29 AM
Hello @Shir Sharvit ,
Lets try to debug the code with added logs
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (control == 'assignment_group') {
var assignmentGroupType = g_form.getDisplayValue('assignment_group.type');
if (assignmentGroupType !== 'itil') {
// Show the checkbox
g_form.setDisplay('u_false_transfer', true);
// Add an informational message
g_form.addInfoMessage('u_false_transfer is visible because Assignment Group type is not itil.');
} else {
// Hide the checkbox
g_form.setDisplay('u_false_transfer', false);
g_form.setValue('u_false_transfer', false);
// Add an informational message
g_form.addInfoMessage('u_false_transfer is hidden because Assignment Group type is itil.');
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2024 09:10 AM
Hello Shir,
You can achieve that using UI Policies, there's an option called 'onLoad' in advanced view, and it will applies when loads the form and also changes the value:
☆ Community Rising Star 22, 23 & 24 ☆