I have this code running in a Gallery and it seems to be working, but the first time I start the app I get this error:
The value ':' cannot be converted to a date or time value. ( or see image )
It's like it's not ready the with the previous tmpOpenHours lookup With(statment).
Arn't they evaluatet in synchronized order?
If I remove WorkMinutes the error do so as well, so it is the cause of it.
I tried to revers the order of tmpOpenHours and WorkMinutes but then the editor shouts at me, soo it seems to want it synchronized.
I can change the source (sharepoint list) to hold the actuall time value like "08:00" instead, but I guess I want to educate myslef and try to understand this.
Any ideas?
With({ tmpLevBookings: Filter(colLeveransBookings7days, RecondDate = DateAdd(varPickedDate, ThisItem.Value, Days) ) },
With({ tmpRecBookings: Filter(colRecondBookings7days, Date = DateAdd(varPickedDate, ThisItem.Value, Days) ) },
With( {tmpOpenHours: LookUp(colOpenHours, DayID = Weekday( DateAdd(varPickedDate, ThisItem.Value, Days), StartOfWeek.Monday )) },
With({ tmpVacancy: Filter(colVacancys, DateStop >= DateAdd(varPickedDate, ThisItem.Value, Days) ) },
With( {WorkersToday: If(tmpOpenHours.NumOfEmployees - Sum(tmpVacancy, NrOfVacancys) < 0, 0, tmpOpenHours.NumOfEmployees - Sum(tmpVacancy, NrOfVacancys) ) },
With( {BreakMinutes: tmpOpenHours.BreaksInMin * WorkersToday },
With( {WorkMinutes: ( DateDiff( TimeValue( tmpOpenHours.StartHour & ":" & tmpOpenHours.StartMin), TimeValue( tmpOpenHours.CloseHour & ":" & tmpOpenHours.CloseMin ), Minutes ) * WorkersToday ) - BreakMinutes },
With({ tmpLevMinutes: If( Sum(tmpLevBookings, Minutes) = Blank(), 0, Sum(tmpLevBookings, Minutes) ),
tmpRecMinutes: If( Sum(tmpRecBookings, Minutes) = Blank(), 0, Sum(tmpRecBookings, Minutes) ) },
With({tmpMinutesLeft: If( WorkMinutes - tmpLevMinutes - tmpRecMinutes - varPickedWashMinutes <= 0, 0, WorkMinutes - tmpLevMinutes - tmpRecMinutes - varPickedWashMinutes ) },
tmpMinutesLeft
)
)
)
)
)
)
)
)
)