Hi @SkiDK ,
Thanks for your reply.
Here is what I need to achieve.
1. I am storing all dates from a table (VacationMaster) which contains all leaves applied by an employee i.e. ourCollection1
2. I am storing all dates that are between from and to date selected from date picker on leave application form i.e. ourColleciton
3. Now I am trying to check if each date in ourColletion exists in ourCollection1 i.e. each LeaveDates of ourColletion is equal to each AppliedDates of ourColletion1 and set value of variable dupleav to true (but as explained variable value cannot be set in ForAll)
4. At this point, if dupleav is true for any 1 of the cases then display a message saying "Leave already applied"
Hope this explains what I am looking to achieve.
I have pasted the code below for reference:-
-------------------------------------------------
Collect(ourCollection, {LeaveDates: ""});
Clear(ourCollection);
ForAll(
AddColumns(
FirstN(
[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31],
DateDiff(FrmDt.SelectedDate, ToDt.SelectedDate, Days) + 1),
"Day",
"Day " & (Value + 1),
"Date1",
DateAdd(FrmDt.SelectedDate, Value, Days)
),
Patch(
ourCollection,
Defaults(ourCollection),
{
LeaveDates: Date1
}
)
);
Collect(ourCollection1, {AppliedDates: ""});
Clear(ourCollection1);
ForAll(Filter(VacationMaster, Requester = EmpList.Selected.Result),
ForAll(
AddColumns(
FirstN(
[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31],
DateDiff(DateValue(FromDate), DateValue(ToDate), Days) + 1),
"Day",
"Day " & (Value + 1),
"Date2",
DateAdd(DateValue(FromDate), Value, Days)
),
Patch(
ourCollection1,
Defaults(ourCollection1),
{
AppliedDates: Date2
}
)
));
UpdateContext({dupleav: false});
ForAll(ourCollection1, (ForAll(ourCollection, If(ThisRecord.LeaveDates = AppliedDates, dupleav = true, dupleav = true))));
-------------------------------------------------
Thanks,
Vishwas.