- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 10:50 PM
Wrote a client script and Display BR on Task table but not working
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2025 02:18 AM
@VijayKummamuru - You can use onCellEdit client script that runs on the list view of the table to control with same logic.
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2025 02:21 AM
you can use list_edit ACLs on those 2 fields to block the field from getting updated in list
OR
you can use onCell Edit and stop the update, something like this
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var saveAndClose = true;
if (!((g_user.hasRoleExactly("service_desk")) || (g_user.hasRoleExactly("incident_manager")) || (g_user.hasRoleExactly("major_incident_manager")))) {
if (newValue.toString() == '1' || newValue.toString() == '2')
alert('Please contact Service Desk to raise priority to Critical or Crisis');
saveAndClose = false;
} else {
saveAndClose = true;
}
callback(saveAndClose);
}
OR
you can use before update business rule
Condition:
Priority Changes to 1 OR Priority Changes to 2 && !((gs.hasRole("service_desk")) || (gs.hasRole("incident_manager")) || (gs.hasRole("major_incident_manager")))
Script:
(function executeRule(current, previous) { // Add your code here
gs.addErrorMessage('Please contact Service Desk to raise priority to Critical or Crisis');
current.setAbortAction(true);
})(current, previous);
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 11:02 PM
Hi @VijayKummamuru ,
Option 1: Move the Display Business Rule to the child table (incident, change_request, etc.)
If you're working specifically with Incidents, update the Display BR:
- Table: incident (not task)
- Leave the rest of your script as-is.
- This will ensure g_scratchpad values are available to the client script.
Option 2: Apply Display BR to all child tables
If you want to keep the BR on Task but apply it to all child tables:
1.In the Display Business Rule:
- Check ✅ Advanced.
- Check ✅ Applies to: All application scopes.
- Check ✅ When: Display.
- Check ✅ Inherited (if visible — allows child tables to inherit the rule).
2.Add a log statement inside the BR to confirm if it's running:
gs.info("Display BR running on: " + current.getTableName());
If my response helped, please hit the 👍Thumb Icon and accept the solution so that it benefits future readers.
Regards,
Pratik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 11:07 PM
@VijayKummamuru - Please use g_user.hasRoleExactly() in the client script to check the current logged has user role assigned instead of Display BR.
Please try with the below onLoad client script and check
function onLoad() {
//Type appropriate comment here, and begin script below
if (!((g_user.hasRoleExactly("service_desk")) || (g_user.hasRoleExactly("incident_manager")) || (g_user.hasRoleExactly("major_incident_manager")))) {
// Remove "Crisis" and "Critical" options from Impact field
g_form.removeOption('impact', '1'); // Crisis
g_form.removeOption('impact', '2'); // Critical
// Remove "High" and "Critical" options from Urgency field
g_form.removeOption('urgency', '1'); // High
g_form.removeOption('urgency', '2'); // Critical
// Show message guiding users to contact Service Desk
g_form.showFieldMsg('priority',
"Please contact Service Desk to raise priority to Critical or Crisis",
"info");
}
}
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2025 02:11 AM
@Vasantharajan N This is working i before but the problem is user still able to change the impact and urgency through List view .can you guide me to solution for that
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2025 02:18 AM
@VijayKummamuru - You can use onCellEdit client script that runs on the list view of the table to control with same logic.
Thanks & Regards,
Vasanth