I have an application which have 3 leave types to select for the leave request,I am using a form control but submitting the data using the Patch Function. I am showing the form fields according to the leave request selected in the dropdown in my form.
and on submit button I have set this Code:
If(DataCardValue1.Selected.Value = "Time Off",
Patch(
LeaveRequests,
{
ID:LeaveGallery.Selected.ID
},
{
LeaveID: CurrentUserID,
User: DataCardValue6.Text,
Requestor: MyUserEmail,
Approver:
{
Claims: Concatenate(
"i:0#.f|membership|",
DataCardValue3.Selected.Email // Person email
),
Department: "",
DisplayName: "",
Email: DataCardValue3.Selected.Email, // Person email
JobTitle: "",
Picture: ""
},
Description: DataCardValue2.Text,
TimeOffDate: DataCardValue22.SelectedDate,
TimeOffFrom: DataCardValue19.Selected,
TimeOffTo: DataCardValue20.Selected,
TotalTimeRequested: Label23.Text,
LeaveStatus:"Pending"
}
),DataCardValue1.Selected.Value = "Annual Leave",
Patch(
LeaveRequests,
{
ID:LeaveGallery.Selected.ID
},
{
LeaveID: CurrentUserID,
User: DataCardValue6.Text,
Requestor: MyUserEmail,
Approver:
{
Claims: Concatenate(
"i:0#.f|membership|",
DataCardValue3.Selected.Email // Person email
),
Department: "",
DisplayName: "",
Email: DataCardValue3.Selected.Email, // Person email
JobTitle: "",
Picture: ""
},
Description: DataCardValue2.Text,
StartDate:StartDate.SelectedDate,
EndDate:EndDate.SelectedDate,
DaysCount:Label25.Text,
LeaveStatus:"Pending"
}
),
DataCardValue1.Selected.Value = "Sick Leave",
Patch(
LeaveRequests,
{
ID:LeaveGallery.Selected.ID
},
{
LeaveID: CurrentUserID,
User: DataCardValue6.Text,
Requestor: MyUserEmail,
Approver:
{
Claims: Concatenate(
"i:0#.f|membership|",
DataCardValue3.Selected.Email // Person email
),
Department: "",
DisplayName: "",
Email: DataCardValue3.Selected.Email, // Person email
JobTitle: "",
Picture: ""
},
Description: DataCardValue2.Text,
StartDate:StartDate.SelectedDate,
EndDate:EndDate.SelectedDate,
DaysCount:Label25.Text,
LeaveStatus:"Pending"
}
),
DataCardValue1.Selected.Value = "Casual Leave",
Patch(
LeaveRequests,
{
ID:LeaveGallery.Selected.ID
},
{
LeaveID: CurrentUserID,
User: DataCardValue6.Text,
Requestor: MyUserEmail,
Approver:
{
Claims: Concatenate(
"i:0#.f|membership|",
DataCardValue3.Selected.Email // Person email
),
Department: "",
DisplayName: "",
Email: DataCardValue3.Selected.Email, // Person email
JobTitle: "",
Picture: ""
},
Description: DataCardValue2.Text,
StartDate:StartDate.SelectedDate,
EndDate:EndDate.SelectedDate,
DaysCount:Label25.Text,
LeaveStatus:"Pending"
}
)
);
Navigate(SucessScreen,None);
after submitting it stores the data into SP list, but when I create another record it overwrites onto the existing one, without creating a new record.
any help?