- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2024 03:32 PM - edited ‎06-26-2024 03:36 PM
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2024 09:22 PM
Could it be access controls on the Schedule? If the user cannot read the schedule, perhaps its not eliminating values correctly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2024 09:22 PM
Could it be access controls on the Schedule? If the user cannot read the schedule, perhaps its not eliminating values correctly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2024 11:54 PM
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