Hello,
I am working on a Canvas App in PowerApps and need to submit data into two Dataverse tables (Visitors and Meetings) with a single button click. Here's the desired workflow:
- Visitors Table: I use a form (
Form1) to collect visitor details and submit it to the Visitors table.
- Meetings Table: After successfully submitting the visitor record, I want to create a related meeting record in the Meetings table using the
Patch function.
Issue:
The Visitors form (Form1) is submitted successfully, but the record in the Meetings table is not being created. In some cases, I get a generic error message without detailed information.
Here is the current code I am using in the button's OnSelect property
// Submit data to Visitors table
SubmitForm(Form1);
// Check if Visitors form submission is valid
If(
Form1.Valid,
// Create a Meeting record
Set(
NewMeetingRecord,
Patch(
Meetings,
Defaults(Meetings),
{
MeetingDate: DateTimeValue(
Text(DateValue1.SelectedDate) & " " & HourValue1.Selected.Value & ":" & MinuteValue1.Selected.Value
),
MeetingDetails: DataCardValue7.Text,
EmployeeEmail: ComboBox1.Selected.userPrincipalName,
VisitorsName: DataCardValue5.Text
}
)
);
// Notify success or failure
If(
!IsError(NewMeetingRecord),
Notify("Visitor and Meeting registered successfully!", NotificationType.Success),
Notify("Error registering Meeting. Please try again.", NotificationType.Error)
)
,
Notify("Error registering Visitor. Please check your input.", NotificationType.Error)
);
// Reset form and navigate to another screen
If(
Form1.Valid && !IsError(NewMeetingRecord),
ResetForm(Form1);
Navigate(EmployeeScreen)
);