hi Expert
i am having error when i try to create a record.
Condition.
1. if admin or super is user is creating a record they can choose for which team they are creating a record for
2. If a team member is creating a record than the team name is automatically selected
now when i am creating the record the second patch is giving me error
Code:
ClearCollect(
DateRange,
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
],
DateDiff(
varDateDetails.startDate,
varDateDetails.endDate,
TimeUnit.Days
) + 1
),
"Day",
"Day " & (Value + 1),
"DailyDate",
DateAdd(
varDateDetails.startDate,
Value,
TimeUnit.Days
)
)
);
If(
IsBlank(TextInput2) Or IsBlank(TextInput2_2) Or IsBlank(TextInput2_7) Or IsBlank(TextInput2_4) Or IsBlank(DatePicker1),
Notify(
"Please fill in all required fields.",
NotificationType.Error
), If(varAdminDelBtn = false,
Set(
varRecordsId,
Patch(
Records,
If(varDateDetails.IsEdit, LookUp(Records, Id = varDateDetails.recordId), Defaults(Records)),
{
'Start Date': varDateDetails.startDate,
'End Date': varDateDetails.endDate,
'Start Time': lblStartTime.Text,
'End Time': lblendTime.Text,
'Booked By': User().Email,
Name: TextInput2.Text & " " & TextInput2_7.Text,
'Booking Date': Now(),
'First Name': TextInput2.Text,
'Last Name': TextInput2_7.Text,
'Middle Name': TextInput2_12.Text,
Gender: TextInput2_2.Text,
'Case Number': TextInput2_4.Text,
'In Custody Flag': TextInput2_5.Text,
'Booking Number': TextInput2_6.Text,
'Date Of Birth ': DatePicker1.SelectedDate,
PodId: Value(varDateDetails.podId),
'Booking Status': "Reserved",
'Status (crbb3_Status)': Dropdown2,
'Organizational Id':Dropdown5.Selected.Value,
Comments:TextInput2_15.Text,
Location:dpPod.Selected.'POD Name',
IsActive: true
}
)
);Notify("Room Reservation Reserved", NotificationType.Success);
Navigate(RecordList);,
Set(
varRecordsId,
Patch(
Records,
If(varDateDetails.IsEdit, LookUp(Records, Id = varDateDetails.recordId), Defaults(Records)),
{
'Start Date': varDateDetails.startDate,
'End Date': varDateDetails.endDate,
'Start Time':lblStartTime.Text,
'End Time':lblendTime.Text,
'Booked By': User().FullName,
Name: TextInput2.Text&" "&TextInput2_7.Text,
'Booking Date': Now(),
Comments:TextInput2_14.Text,
Location:dpPod.Selected.'POD Name',
'First Name': TextInput2.Text,
'Last Name': TextInput2_7.Text,
'Middle Name':TextInput2_13.Text,
Gender: TextInput2_2.Text,
'Case Number': TextInput2_4.Text,
'In Custody Flag': TextInput2_5.Text,
'Booking Number': TextInput2_6.Text,
'Booking Status':"Reserved",
'Date Of Birth ': DatePicker1.SelectedDate,
PodId: Value(varDateDetails.podId),
'Organizational Id': Dropdown5_1.Selected.Value,
'Status (crbb3_Status)':Dropdown2,
IsActive: true
}
)
),
ForAll(
DateRange,
Patch(
'Record Histories',
Defaults('Record Histories'),
{
RecordId: Value(varRecordsId.Id),
BookedDate: DailyDate,
PodId: Value(varDateDetails.podId),
IsActive: true
}
)
);
);
If(
varDateDetails.IsEdit,
RemoveIf('Record Histories', RecordId = Value(varDateDetails.recordId))
);
ForAll(
DateRange,
Patch(
'Record Histories',
Defaults('Record Histories'),
{
RecordId: Value(varRecordsId.Id),
BookedDate: DailyDate,
PodId: Value(varDateDetails.podId),
IsActive: true
}
)
);
ForAll(DateRange,
Patch(
'Record Dates',
If(CountRows(Filter('Record Dates', Date = DailyDate, PodId = Value(varDateDetails.podId))) > 0, LookUp('Record Dates', Date = DailyDate), Defaults('Record Dates')) ,
{
Date: DailyDate,
PodId: Value(varDateDetails.podId),
Count: CountRows(Filter('Record Histories', BookedDate = DailyDate, PodId = Value(varDateDetails.podId), IsActive))
}
)
);
Notify("Room Reservation Reserved", NotificationType.Success);
Navigate(
RecordList,
ScreenTransition.Fade
);
Reset(TextInput2);
Set(
varAvailability,
false
);
Reset([@dpPod]);
Reset(TextInput2_2);
Reset(TextInput2_7);
Reset(TextInput2_12);
Reset(TextInput2_6);
Reset(DatePicker1);
Reset(TextInput2_4);
Reset(dpFromDate_1);
Reset(dpToDate_1);
Reset(TextInput2_15));

Report
All responses (
Answers (