Major incident fields visible and updated 48hours after resolved
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2024 06:16 PM
I need 2 fields on the major incident tab to be visible and editable only by a specific group and for these fields to become mandatory whenever the major incident state is accepted, and remain editable for 48 hours after the incident is resolved. Please, could someone help me?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2024 07:25 AM
To achieve this, use ACLs to restrict visibility and editing of the fields to the specific group. Create a Business Rule to make the fields mandatory when the state changes to "Accepted." Add another Business Rule to keep the fields editable for 48 hours after resolution using GlideDateTime to calculate the time window. Test the setup thoroughly before deploying. Let me know if you need detailed scripts!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2024 09:09 AM
@saintjoseph Can you help with detailed scripts, please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2024 06:52 PM
Hi @Maria Lucia da ,
you can take a reference from below article, it has incident auto closer in 3 working days, change the table name and state value.
https://servicenowwithrunjay.com/auto-close-incident-after-3-business-days/
Accept and mark helpful it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2024 08:53 PM
you can make those 2 fields as visible and editable based on display BR and onLoad client script
Now in that same display BR you can check the resolved time and compare now time and if it's within 48 hours then only make it editable
Something like this, please enhance it further
Display business rule
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var flag = 'false';
var resolvedTime = current.getValue('resolved_at'); // Replace with the actual resolved time field
if (resolvedTime) {
var resolvedDate = new GlideDateTime(resolvedTime);
var currentDate = new GlideDateTime();
var diff = GlideDateTime.subtract(currentDate, resolvedDate);
var hours = diff.getNumericValue() / (1000 * 60 * 60);
if (hours <= 48 && gs.getUser().isMemberOf('GroupName')) {
flag = 'true';
}
}
g_scratchpad.showFields = flag;
})(current, previous);
onload client script:
function onLoad(){
if(g_form.getValue('state') == '6' && major incident state == 'accepted' && g_scratchpad.showFields == 'true'){
// show fields make editable and mandatory
}
else{
// hide fields
}
}
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