Saturday 5 February 2022

How to submit the data to multiple SharePoint lists in Power Apps

I have created below two SharePoint lists:

Customer Info: CustomerName(Title), CustomerID, ContactNumber, Country

Product Info: Title, Customer, CustID, Price

I have added Gallery and EditForm controls on the same screen and connected to 'CustomerInfo' SharePoint list as a data source.

Using the 'AddColumns' function I have added a new column to the result in Gallery control and I have set the result to new label control Refer my previous post here.

Fyi.. I am fetching the Price value from ProductInfo list.

In Button OnSelect property, SubmitForm(Form2_1) is updating the record in CustomerInfo list since it is the main source which is connected as data source. 

But I also need to update the Price value in ProductInfo list which is the main source of this field.

SubmitForm(Form2_1);
Patch(
    ProductInfo,
    If(
        FormMode = "New",
        Defaults('ProductInfo'),
        LookUp(
            ProdColll,
            CustID = DataCardValue2_1.Text
        )
    ),
    {Price: DataCardValue5_1.Text}
);

Here:

ProductInfo: Is the list where i wanted to update the Price field value.

Defaults(ProductInfo): This will create the new record if the formmode is New.

In Lookup: From the collection(ProdColll), I am comparing the CustID value and updating the datacard value in Price field.

No comments:

Post a Comment