Hello,
I want to know how i can relate this to Patch functions ?
Patch(Reservierungs;Defaults(Reservierungs); {StartDatum: StartDatum_DataCard2.Update; EndDatum: EndDatum_DataCard2.Update; 'Personen anzahl': 'Personen anzahl_DataCard2'.Update});;Patch(Kundes;Defaults(Kundes); {Vorname: Vorname_DataCard1.Update;Nachname: Nachname_DataCard1.Update;Telefon: Telefon_DataCard1.Update;'E-Mail': 'E-Mail_DataCard1'.Update});;Navigate(Screen1)
can you please help me if you need something else please ask questions.
With best reagards
Philipp Peter
Why would you like to relate the patch functions? Does one of the 2 tables contain a Look Up in which you would like to add the recently created record of the other table?
In this case you can save a created record by encapsulating the patch in a variable (which you can later use in a LookUp column):
Set(varName, Patch(YourPatchValues))
I hope this helps!
Explanation:
I have two tables
Table 1 Customer
Table 2 Reservations
Lookup column: CustomerID
Between these tables I have now created a relationship with the column CustomerID which is in the table Reservations.
Now I want to use the patch function to put new data via Power Apps into the reservation table but also into the customer table.
The scenario is like this:
1. customer goes into the app and creates a new customer in the customer table in the customer table a customer ID is generated.
2. customer creates a reservation in the app in the reservation table, in the reservation table the allocation to the previously created customer should happen but I haven't come up with an idea yet.
I thought I needed the "Relate" function for this, but maybe it works without it?
My question is how can I create the relation to the previously created customer via the "Patch" function?
Code at this time (Writes only the date but does not establish a relationship):
________________________________
Patch(
Reservation;
Defaults(Reservation);
{
StartDate: StartDate_DataCard2.Update;
EndDate: EndDate_DataCard2.Update;
'Number of persons': 'Number of persons_DataCard2'.Update;
}
);;
Patch(
Customers;
Defaults(Customers);
{
First Name: FirstName_DataCard1.Update;
Surname: LastName_DataCard1.Update;
'Phone': 'Phone_DataCard1.Update;
'Email': 'Email_DataCard1'.Update
}
);;
ResetForm(Form3);;
ResetForm(Form4);;
Navigate(Screen1)
________________________________
@Philipp-Peter the relate() function I mainly use in many-to-many relationships.
In this case I would use the following code to achieve your goal:
(1) First Patch your customer and save the record in a variable
Set(varName,
Patch(
Customers;
Defaults(Customers);
{
First Name: FirstName_DataCard1.Update;
Surname: LastName_DataCard1.Update;
'Phone': 'Phone_DataCard1.Update;
'Email': 'Email_DataCard1'.Update
}
)
);;
You might need to change varName, to varName; (I am not familiar with the ; and ;; syntax)
(2) Now that you saved the customer record in the variable, you can use it in the reservation patch:
Patch(
Reservation;
Defaults(Reservation);
{
StartDate: StartDate_DataCard2.Update;
EndDate: EndDate_DataCard2.Update;
'Number of persons': 'Number of persons_DataCard2'.Update;
CustomerLookUp: varName
}
);;
I hope this helps!
User | Count |
---|---|
261 | |
110 | |
90 | |
54 | |
44 |