Some variable is not showing in SOW and native view.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
I have a catalog where i have some variable 4 variables are: applicable timeline->Select box->with values Yearly, Quarterly, Monthly. when each value is selected appropriate variable will get visible : applicable year -> Single text ->current year applicable month ->Select box-> with months applicable quarter->select box with q1, q2, q3, q4. varibles are hidden false intially. i am using onload and on change catalog client script: When filling the form everything is working as expected. After submission when checked the additional details in ESC then also everything is fine, but when i opened the RITM SOW/ native view i can't see any on the sub variables (applicable month, year, quarter according to selection). when i deactivated the client script then it was visible but then the form is behaving as expected. i checked and confirmed that the values are captured in sc_item_option_mtom as expected. pls help me to fix this:
On LOAD Script:
function onLoad() { var timeline = g_form.getValue('applicable_timeline'); // Hide all fields g_form.setDisplay('applicable_year', false); g_form.setDisplay('applicable_month', false); g_form.setDisplay('applicable_quarter', false); // Remove mandatory from all g_form.setMandatory('applicable_year', false); g_form.setMandatory('applicable_month', false); g_form.setMandatory('applicable_quarter', false); // Show & make mandatory if (timeline == 'Yearly') { g_form.setDisplay('applicable_year', true); g_form.setMandatory('applicable_year', true); g_form.setDisplay('applicable_month', false); g_form.setDisplay('applicable_quarter', false); g_form.setMandatory('applicable_month', false); g_form.setMandatory('applicable_quarter', false); g_form.clearValue('applicable_month'); g_form.clearValue('applicable_quarter'); } else if (timeline == 'Monthly') { g_form.setDisplay('applicable_month', true); g_form.setMandatory('applicable_month', true); g_form.setDisplay('applicable_year', false); g_form.setDisplay('applicable_quarter', false); g_form.setMandatory('applicable_quarter', false); g_form.setMandatory('applicable_year', false); //g_form.clearValue('applicable_year'); g_form.clearValue('applicable_quarter'); } else if (timeline == 'Quarterly') { g_form.setDisplay('applicable_quarter', true); g_form.setMandatory('applicable_quarter', true); g_form.setDisplay('applicable_month', false); g_form.setDisplay('applicable_year', false); g_form.setMandatory('applicable_year', false); g_form.setMandatory('applicable_month', false); g_form.clearValue('applicable_month'); // g_form.clearValue('applicable_year'); } }
ON CHANGE:
function onChange(control, oldValue, newValue, isLoading) { if (isLoading || newValue == '') { return; } // Hide all fields g_form.setDisplay('applicable_year', false); g_form.setDisplay('applicable_month', false); g_form.setDisplay('applicable_quarter', false); // Remove mandatory from all fields g_form.setMandatory('applicable_year', false); g_form.setMandatory('applicable_month', false); g_form.setMandatory('applicable_quarter', false); // Show the selected field and make it mandatory switch (newValue) { case 'Yearly': g_form.setDisplay('applicable_year', true); g_form.setMandatory('applicable_year', true); g_form.setDisplay('applicable_month', false); g_form.setDisplay('applicable_quarter', false); g_form.setMandatory('applicable_month', false); g_form.setMandatory('applicable_quarter', false); g_form.clearValue('applicable_month'); g_form.clearValue('applicable_quarter'); break; case 'Monthly': g_form.setDisplay('applicable_month', true); g_form.setMandatory('applicable_month', true); g_form.setDisplay('applicable_year', false); g_form.setDisplay('applicable_quarter', false); g_form.setMandatory('applicable_quarter', false); g_form.setMandatory('applicable_year', false); //g_form.clearValue('applicable_year'); g_form.clearValue('applicable_quarter'); break; case 'Quarterly': g_form.setDisplay('applicable_quarter', true); g_form.setMandatory('applicable_quarter', true); g_form.setDisplay('applicable_month', false); g_form.setDisplay('applicable_year', false); g_form.setMandatory('applicable_year', false); g_form.setMandatory('applicable_month', false); g_form.clearValue('applicable_month'); //g_form.clearValue('applicable_year'); break; } }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
try this
Removed "Applies on Requested item" checkbox from both of your catalog client scripts
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @NeethuB
- Your scripts might be restricted to the Desktop UI type or missing the configuration to run on target records (RITMs/Tasks). Change UI type to All
- When an default/ SOW view loads, the onChange script does not automatically fire because the user is not actively changing the applicable timeline field.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti