Script Include does not work correctly for non-admin users

dabulO7
Tera Contributor

Hello,

I have got a task to highlight due date field on a list view in accordance with some specific time conditions. This is implemented fine. I created a Script Include and put it under the field style for Incident table/due date value field.
In the Script Include, I did the calculation with the use of Duration Calculator appending a schedule and when checking this as an admin - outcome is just fine. When checking the same as a non-admin user - it highlights stuff (so the Script Include is being called) but too much - as if it was not taking into consideration the calculation, only the GlideRecord.

 

 

 

var dueDateSchedule = Class.create();
dueDateSchedule.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    dueDateCalendar: function(current) {
        var encodedQuery = 'due_dateISNOTEMPTY^due_dateRELATIVEGT@minute@ahead@0^due_dateRELATIVELT@dayofweek@ahead@7^company.u_customer_preference!=4802b7b3db58bb00217a80e2399619e4^company.u_customer_preference!=4c51c4cc87f7f4905ff4a9383cbb357a^NQdue_dateISNOTEMPTY^due_dateONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()^company.u_customer_preference!=4802b7b3db58bb00217a80e2399619e4^company.u_customer_preference!=4c51c4cc87f7f4905ff4a9383cbb357a';
        //Validate that the current record passes the above encodedQuery condition
        var passedEncodedQuery = GlideFilter.checkRecord(current, encodedQuery);

        //If it doesn't (e.g due date is empty)
        //we return false to not apply the field style
        if (!passedEncodedQuery)
            return false;

        var gdt = new GlideDateTime();
        var dur = new DurationCalculator();
        //Getting the today's date only + hardcoded 0AM for calculation
        var onlyDate = gdt.getDate();
        var time1 = '0:00:00';
        var now = new GlideDateTime();
        var added = onlyDate + " " + time1;
        now.setValue(added);

        dur.setSchedule('2a13e7ad87e6ce10764276a7cebb353a');
        dur.calcScheduleDuration(now, current.getValue('due_date'));

        var businessTimeDiff = Math.floor(dur.getSeconds() / 3600); //Business time in hours
        //var totalTimeDiff = Math.floor(dur.getTotalSeconds() / 3600); //Total time in hours

        if (businessTimeDiff < 69 && businessTimeDiff >= 0)
            return true;

        return false;
    },

    type: 'dueDateSchedule'
});

 

 


Any ideas regarding this?

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Could it be access controls on the Schedule? If the user cannot read the schedule, perhaps its not eliminating values correctly.

View solution in original post

2 REPLIES 2

Community Alums
Not applicable

Could it be access controls on the Schedule? If the user cannot read the schedule, perhaps its not eliminating values correctly.

dabulO7
Tera Contributor

haha Aidan you are correct - appreciate your input, was tackling with the code instead of check the accesses - it was the domain thing that did not let non-admin make use of the schedule. It works fine. Thanks, appreciate! cheers