- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2023 07:55 AM - edited 02-19-2023 07:59 AM
Hi all,
I need to show a tab/section below called "business analysis" with all the fields in it, on the change form, ONLY when the state is "implement" and ONLY when the close code(closure information) is "successful" or "successful with issues".
"business analysis" tab/section is located next to the closure information section.
Can anyone help with the script? Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2023 08:19 PM
@cicgordy I am sharing below working and tested code and please try with UI policy as client script might be required multiple to achieve same, so here would be UI policy as best option.
Create a UI Policy with condition state=implement and closure code is one of "successful" or "successful with issues". -> save UI policy -> click on script tab -> paste in Execute if True g_form.setSectionDisplay('business_analysis',false); -> paste in Execute if false g_form.setSectionDisplay('business_analysis',true);
Imp: tab section name convention is considered as, example if tab section name is 'Related Records' , then you have take 'related_records' in your code.
Example i have tried as i dont have business_analysis section tab, so i have considered different one 'related records' for section tab and selected any random value to share with you:
1. created UI policy:
2. used script to hide section tab:
Hope this will help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2023 09:12 PM
Can you share what script you started?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2023 10:51 PM
Hello @cicgordy
Can you Please try onChange client script in state Field
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
if (newValue == -1 && g_form.getValue('close_code') == 'successful_issues') {
g_form.setSectionDisplay('<Your_Section_Name>', true);
} else {
g_form.setSectionDisplay('<Your_Section_Name>', false);
}
}
if (newValue == -1 && g_form.getValue('close_code') == 'successful_issues') {
g_form.setSectionDisplay('<Your_Section_Name>', true);
} else {
g_form.setSectionDisplay('<Your_Section_Name>', false);
}
}
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates