End date not calculating properly
Hey so this is the code I'm using to get the minimum start and minimum end of shifts for a roster to create it's title, that are linked from relationship fields.
Usually this works fine, but I'm having an odd issue where it's not calculating the end time correctly, it's displaying another shifts end time instead of the one with the max, is there anything noticeably wrong with my coding? Sometimes I have to manually edit the shift date/time fields to get the title to update.
var start = moment(@Min of Time/Date Start).tz('Australia/Brisbane').format("D MMM h:mma")
var end = moment(@Max of Time/Date End).tz('Australia/Brisbane').format("D MMM h:mma")
var TeamsDuplicateCheck = @All of Export Teams.filter(function(elem, pos,arr) {
return arr.indexOf(elem) == pos;
});
var AreasDuplicateCheck = @All of Export Area/s.filter(function(elem, pos,arr) {
return arr.indexOf(elem) == pos;
});
var CategoryDuplicateCheck = @All of Category.filter(function(elem, pos,arr) {
return arr.indexOf(elem) == pos;
});
"(" + TeamsDuplicateCheck.join(", ") + ") " + AreasDuplicateCheck.join(", ") + " (" + CategoryDuplicateCheck.join(", ") + " " + start + " - " + end + ")"
-
Hi Brock,
perhaps one of the other fields (you get with @All of ...) is empty in one item. If you have a null-value in one item you'll get problems with the mapping of the arrays. There are perhaps workarounds, but it depends on your app setup. Maybe you could share some more details about the app relations and waht you want to achieve with the DuplicateCheck-vars.
Rainer
-
Hi Rainer,
Oh so those @all arrays could be interfering with the date field arrays?
The DuplicateCheck-vars are there because shifts are filled out with the text fields from related records 'areas, teams and categories', then they are related to a roster (another app), the roster then calculates the correct title using the code above based on those related shifts. I had to remove the duplicates because otherwise it was just joining all of those text fields together.
Thanks for your help!
Please sign in to leave a comment.
Comments
2 comments