0

How to create a new record in SharePoint list with a lookup column from a button?

SharePoint list "tbl-one" has a lookup column "Contract" and other columns "Title" and "Payment".

Patch(
    tbl_one,
    Defaults(tbl_one),
    {
        Contract: {
            Value: "Test name"
        },
        Title: "16",
        Payment: 160,
    }
)
1

1 Answer 1

2

Ideally you have to pass the item ID from lookup parent list as well in Patch function.

Example:

Patch(
    'Site Inspections',
    LookUp('Site Inspections', ID=1),
    {
        BranchLocationLookUp: {
            Id: 2,
            Value: "Minneapolis, MN"
        }
    }
)

So, pass the item ID from your parent list.

Assuming your parent lookup list name is Contracts and primary lookup column from parent list is Title, you can use formula like:

Patch(
    tbl_one,
    Defaults(tbl_one),
    {
        Contract: {
            Id: LookUp(Contracts, Title="Test name", ID)
            Value: "Test name"
        },
        Title: "16",
        Payment: 160,
    }
)

References:

  1. PATCH A SharePoint LookUp Column In Power Apps
  2. How to patch a SharePoint Lookup Column?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.