Omit new button for problem task related list on problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 03:01 AM - edited 02-19-2024 04:14 AM
Hi,
Once the problem record is assigned to a problem coordinator, no other users should have access to create a PTASK from problem task related list except Problem Manager.
from problem task list control in omit new condition tab there is a ootb code already am trying to put my conditions as below but its not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 08:57 PM
please try to ensure you update the code so that it doesn't disturb OOB condition
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-2024 09:36 PM
Hi @Alekhya12
Here’s a refactored version that should typically work:
// Get a reference to the current problem record
var probRecord = new GlideRecord(‘problem’);
probRecord.get(current.sys_id);
// Check if the current user is a problem manager
var userIsProblemManager = gs.hasRole(‘problem_manager’);
// Check if the problem is assigned to a coordinator (assuming ‘assigned_to’ field is populated)
var problemAssignedToCoordinator = probRecord.assigned_to != null && probRecord.assigned_to != ‘’;
// The New button should be hidden if the user is not a problem manager AND the problem is already assigned to a coordinator
answer = !(userIsProblemManager || !problemAssignedToCoordinator);
Please Mark this as Helpful/ Correct if this solves your query