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

@SANDEEP28, Assignment group and Schedule are not same.

I said SLA name and Assignment group names are same.

 

So we need to write query based on SLA table to get values from schedule and in schedule having schedule entries.

Could you please update the script and share it to me.

 

 

Thanks,

Abdul

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

 

 

@SANDEEP28 Its working, Thank you so much.

Could you please let me know if Schedule is having more no.of schedule entries how it will work.

 

And if a schedule is having child entries with holidays based on their timezone, how should it will work.

 

in our system having Schedule entries and Child entries.

Schedule entries for weekly bases.

Child entries for all Holidays os the year based on country.

 

please answer this to me.

 

Thanks,

Abdul

@Abdul333 Not sure about this . You can open new thread for this question and so that others will help you out. Accept the previous answer as it worked for you. It will help others if they come across same requirement.

@SANDEEP28 Thank you so much, I accepted the solution.

 

Here one more point is pending in my requirement, need hide that Reminder button for next two hours. So no member can send a reminder within 2hours. Please help me on this how we can write script for, please share the steps and query.

 

Thanks,

Abdul