- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 08:00 AM
Hello All,
I have Requirement that to hide the UI Action button after business hours of the assignment group.
I created a UI Action button called "Send Reminder".
We need to show this Button based on assignment group Business hours.
Business hours are different for each assignment group, based on their location.
We have users from Worldwide.
Is there any possible way to implement this?
We have a field called Schedule, in that schedule we added the days of the week and timing.
please check the attached screenshot.
this is foe one assignment group, we have one functionality like if a schedule ends with JP, its for Japan, Ru for Russia like that.
Here we need hide that button after 17(5PM) and before 9AM and we need hide for saturday and sunday also.
please check and help us to get this implemented.
@Ankur Bawiskar @SANDEEP28 @Community Alums
Thanks,
Abdul
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 10:11 PM
@Abdul333 As you confirmed that SLA name and assignment group name is same then put below code in script include
var IncidentReminder = Class.create();
IncidentReminder.prototype = {
initialize: function() {},
visibilityBasedOnSchedule: function(groupName) {
var grSla = new GlideRecord('contract_sla');
if (grSla.get('name', groupName)) {
var gsSchedule = new GlideSchedule(grSla.getValue('schedule'));
var todayDateTime = new GlideDateTime();
if (gsSchedule.isInSchedule(todayDateTime))
return true;
else
return false;
} else {
return false;
}
},
type: 'IncidentReminder'
};
UI action Condition -
new global.IncidentReminder().visibilityBasedOnSchedule(current.assignment_group.getDisplayValue());
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 08:09 AM
then do this
1) create script include and pass the group sysId
2) check the schedule for that group and check if current date/time is in schedule or not
3) pass the current group to script include from UI action condition current.groupField
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 08:13 AM
Hi @Abdul333 ,
There are two scenarios,
- if it has to be hidden on form load, you can create a ScriptInclude which returns true/false and call that script include (need to pass assignment group) in the UI Action condition.
- If it has to be hidden if you change the assignment group after form load, you have to call the same script include using GlideAjax from an onChange client script then use DOM manipulation to hide the button.
Let me know if you need any more help.
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 09:53 PM
Hi @AnveshKumar M ,
Based schedule entries of the SLA, we need to show the button.
For example, please find the below screenshot.
here you can see the name of the schedule entry from 9-17, and see the timezone.
and repeat on we can see the check boxes for days.
SO we need to show the button for highlighted days and time frame b/w 9AM-17(5PM).
like this we have so many SLAs with different time zones.
Reminder should visible based on SLA hours of assignment groups
For Example, lets take two Assignment Groups as an example.
"In:assignmentgroup:1st " is having Business hour from Monday-Friday 08:00-17:00 hours IST.
"In: assignmentgroup1:2nd " is having Business hour from Monday-Friday 09:00-17:00 hours CET
Assume one ticket is assigned to " in:assignmentgroup:1st " group and they route the ticket to 2nd level group " in: assignmentgroup1:2nd " and then 2nd level group route the ticket back to first level.
Around 14:00CET (17:30 IST - Already outside of Business Hours for first level) they seeing ticket they routed to first level is not yet assigned and no one is working.
In this case Send Reminder button should not be shown to members in "in: assignmentgroup1:2nd " to trigger Notification since it is already outside of Business Hours.
If currently Assigned Assignment group is still in Business hours, then it should show Send Reminder button to trigger Notification.
Please have a look and do needful help with providing solution.
Thanks,
Abdul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2023 05:21 AM
@Abdul333 I hope you are adding schedule in the "Schedule entries" related list in the Assignment group record .
Create script include called as "IncidentReminder" and add below function in the script section
var IncidentReminder = Class.create();
IncidentReminder.prototype = {
initialize: function() {},
visibilityBasedOnSchedule: function(groupID) {
var grScheduleSpan = new GlideRecord('cmn_schedule_span');
if (grScheduleSpan.get('group', groupID)) {
var gsSchedule = new GlideSchedule(grScheduleSpan.getValue('schedule'));
var todayDateTime = new GlideDateTime();
if (gsSchedule.isInSchedule(todayDateTime))
return true;
else
return false;
} else {
return false;
}
},
type: 'IncidentReminder'
};
Then call this function from UI action by putting below line of code in condition field.
new global.IncidentReminder().visibilityBasedOnSchedule(current.assignment_group);
I have tested this and its working.
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!