How to Hide a Button based on Business/Working Hours of the Assignment Group.

Abdul333
Tera Contributor

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.

 

Abdul333_0-1691506578234.png

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

 

 

1 ACCEPTED SOLUTION

@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 !! 

 

 

View solution in original post

16 REPLIES 16

@Ankur Bawiskar could you please help on this.

Need to hide the "Send Reminder" button for next 2hours once reminder sent.

 

 

Thanks,

Abdul

Aman Kumar S
Kilo Patron

I believe the best possible solution would not be creating a solution to hid the UI action, that will have considerable impact on the performance, because every time the form loads, this script will run and server lookup will happen to compute whether the current time is within schedule.

 

I would rather suggest, to have annotation on the form displaying that this UI action is only usable during office hours, and have the condition, so once the UI action is clicked, it will validate if current time is within schedule, if it is outside, abort action else let the functionality to go ahead.

Hope this helps, let me know if there are any queries.

 

Best Regards
Aman Kumar