Having some issues with a save button. Have several formulas on the OnSelect. At the moment this runs correctly once. The first patch runs correctly every time, the second patch runs correctly once. First patch sends the input information to a second sharepoint list (Dates), second Patch goes to (Employee Names)
Do I even need the SubmitForm with the patches? Should I just patch everything?
This form is updated daily.
Patch(Dates, Defaults(Dates),{Name:Value(DataCardValue12.Text),CheckInDate:Value(DataCardValue15_CheckInDate.SelectedDate),Reason:Value(DataCardValue18_ReasonOut.Selected.Value),SickHoursTaken:Value(DataCardValue1_SickHours.Text),VacationHoursTaken:Value(DataCardValue23_VacationHoursTaken.Text)});
SubmitForm(Form2);
Set(currentRecord, LookUp('Employee Names', ID = Value(DataCardValue45.Text)));
Patch('Employee Names',currentRecord,{SickHoursTaken:Value(DataCardValue1_SickHours.Text), SickAvailableNow:currentRecord.SickAvailableNow - Value(DataCardValue1_SickHours.Text)});Patch('Employee Names',currentRecord,{VacationHoursTaken:Value(DataCardValue23_VacationHoursTaken.Text), VacationAvailable:currentRecord.VacationAvailable - Value(DataCardValue23_VacationHoursTaken.Text)});
Notify("Record Saved",NotificationType.Success);
Solved! Go to Solution.
Hi @adyboon ,
Short answer - you should not mix SubmitForm and Patch on the same data source in the same bit of code.
A couple of other things
So try below - note I free-typed it so watch commas/brackets etc.
Patch(
Dates,
Defaults(Dates),
{
Name: DataCardValue12.Text,
CheckInDate: DataCardValue15_CheckInDate.SelectedDate,
Reason: DataCardValue18_ReasonOut.Selected.Value,
SickHoursTaken:Value(DataCardValue1_SickHours.Text),
VacationHoursTaken:Value(DataCardValue23_VacationHoursTaken.Text)
}
);
UpdateIf(
'Employee Names',
LookUp(
'Employee Names',
ID = Value(DataCardValue45.Text)
),
{
SickHoursTaken:Value(DataCardValue1_SickHours.Text),
SickAvailableNow:
'Employee Names'.SickAvailableNow - Value(DataCardValue1_SickHours.Text)),
VacationHoursTaken:Value(DataCardValue23_VacationHoursTaken.Text),
VacationAvailable:
'Employee Names'.VacationAvailable - Value(DataCardValue23_VacationHoursTaken.Text)
}
);
Refresh('Employee Names');
Refresh(Dates);
Notify("Record Saved",NotificationType.Success)
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Hi @adyboon ,
Short answer - you should not mix SubmitForm and Patch on the same data source in the same bit of code.
A couple of other things
So try below - note I free-typed it so watch commas/brackets etc.
Patch(
Dates,
Defaults(Dates),
{
Name: DataCardValue12.Text,
CheckInDate: DataCardValue15_CheckInDate.SelectedDate,
Reason: DataCardValue18_ReasonOut.Selected.Value,
SickHoursTaken:Value(DataCardValue1_SickHours.Text),
VacationHoursTaken:Value(DataCardValue23_VacationHoursTaken.Text)
}
);
UpdateIf(
'Employee Names',
LookUp(
'Employee Names',
ID = Value(DataCardValue45.Text)
),
{
SickHoursTaken:Value(DataCardValue1_SickHours.Text),
SickAvailableNow:
'Employee Names'.SickAvailableNow - Value(DataCardValue1_SickHours.Text)),
VacationHoursTaken:Value(DataCardValue23_VacationHoursTaken.Text),
VacationAvailable:
'Employee Names'.VacationAvailable - Value(DataCardValue23_VacationHoursTaken.Text)
}
);
Refresh('Employee Names');
Refresh(Dates);
Notify("Record Saved",NotificationType.Success)
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
User | Count |
---|---|
204 | |
93 | |
84 | |
47 | |
42 |
User | Count |
---|---|
251 | |
104 | |
104 | |
62 | |
57 |