In Change Table, Field should be mandatory and visible only to Change Manager in New State.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2025 01:15 AM
In Change Table, Field should be mandatory and visible only to Change Manager in New State.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2025 01:34 AM
Hi @SajithM ,
You can use a UI policy to set the fields mandatory and visible , then use the run scripts option like below:
function onCondition() {
if(!g_user.hasRoleExactly('change_manager')) {
g_form.setReadOnly('<name_of_field>', true);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2025 06:49 AM
No Luck, Not sure what's the issue though.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2025 01:57 AM
Hi @SajithM
You didn’t specify which field should be mandatory and why, specifically for the Change Manager. You can follow the UI policy as suggested by @Sandeep Dutta . Also, since it is mandatory only for the Change Manager, make sure that the field is visible in the new state.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2025 01:57 AM
you can use onLoad client script for this
function onLoad() {
var isChangeManager = g_user.hasRoleExactly('change_manager');
var currentState = g_form.getValue('state');
var fieldName = 'your_field_name'; // Replace with your actual field name
if (currentState.toString() == '-5') { // Assuming 'New' state value is '-5'
g_form.setVisible(fieldName, isChangeManager);
g_form.setMandatory(fieldName, isChangeManager);
} else {
g_form.setVisible(fieldName, true);
g_form.setMandatory(fieldName, false);
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
