Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Patch from Form Submit button to lookup field

(0) ShareShare
ReportReport
Posted on by

Good Morning 

 

I am trying to patch a new record from a "Create New' button on a Form 

 

I am currently using 

 

Patch('Suggested Travel', Defaults('Suggested Travel'), {BookingRef: DataCardValue9})

 

The BookinRef field in my SharePoint list is a lookup column from another table. 

 

When I click submit it creates the record but does no update the BookingRef field in my sharepoint list 

 

Since it is a lookup do I need to add something to my patch. 

 

Thank you

 

  • Sn3l Profile Picture
    on at
    Re: Patch from Form Submit button to lookup field

    Thank you so so much for all your help.  It is working.   You need 10 thumbs up for all your help.  Thank you again 

     

     

  • Verified answer
    Anonymous_Hippo Profile Picture
    1,247 Super User 2024 Season 1 on at
    Re: Patch from Form Submit button to lookup field

    Hello @Sn3l ,

     

    Thank you for catching that error ! I created a test case and the above formula seems to be working for me, Most probably something else is going wrong. Can you add the following in the on success property

    Patch(
     'Suggested Travel',
     LookUp(
     'Suggested Travel',
     ID = LastSubmitID
     ),
     {BookingRef: {'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
     Id: DataCardValue9.Selected.Id,
     Value: DataCardValue9.Selected.Value
     }
     }
    );
    Notify("Data was patched successfully",NotificationType.Success,5000);

    Anonymous_Hippo_0-1666625178797.png

     

    Now when you submit the form are you seeing the above message ? if yes then it means that your form submit is working correctly. If no then your submit form might have some issues

     

    Check your actual data source and see if any data is getting updated ? Also look if the variable lastformsubit has a value in it, all of this should give you clues into why it is not working

  • Sn3l Profile Picture
    on at
    Re: Patch from Form Submit button to lookup field

    With the following no error.  But nothing happens

     

    Patch(
     'Suggested Travel',
     LookUp(
     'Suggested Travel',
     ID = LastSubmitID
     ),
     {BookingRef: {'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
     Id: DataCardValue9.Selected.Id,
     Value: DataCardValue9.Selected.Value
     }
     }
    )
  • Sn3l Profile Picture
    on at
    Re: Patch from Form Submit button to lookup field

    Thank you so much for your help. 

     

    I get Invalid Argument error. 

     

    Screenshot 2022-10-24 095917.png

  • Anonymous_Hippo Profile Picture
    1,247 Super User 2024 Season 1 on at
    Re: Patch from Form Submit button to lookup field

    Hello @Sn3l ,

     

    I missed the fact that this is a lookup column . Dummy me !

     

    Lookup columns are special columns and have a particular schema. Therefore can you please try this

     

     

    Patch(
     'Suggested Travel',
     LookUp(
     'Suggested Travel',
     ID = LastSubmitID
     ),{
    BookingRef: {'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
     Id: DataCardValue9.Selected.Id,
     Value: DataCardValue9.Selected.Value
     
     }}
    )

     

     

     

    THis should definetly work ! Else please post the error that you are seeing 

  • Sn3l Profile Picture
    on at
    Re: Patch from Form Submit button to lookup field

    Hi @Anonymous_Hippo 

     

    Thank you so much for the help. 

     

    Can confirm that it is indeed a value field.  It does however not trigger anything and still does not like the .value. 

     

    I have also tried  

     

    Patch(
     'Suggested Travel',
     LookUp(
     'Suggested Travel',
     ID = LastSubmitID
     ),
     {BookingRef: {Value:DataCardValue9})

    With no luck - No event on "OnSelect" 

  • Anonymous_Hippo Profile Picture
    1,247 Super User 2024 Season 1 on at
    Re: Patch from Form Submit button to lookup field

    Hello @Sn3l ,

     

    Can you Try 

    {BookingRef:DataCardValue9.Selected.Value})

    If you are seeing an error then select the combobox and go to its advanced property and look at the DisplayField if the value in that square bracket is not ["Value"] then replace with whatever value that you see. For example in the below case i will replace my formula with

    {BookingRef:DataCardValue9.Selected.Country})

    Anonymous_Hippo_1-1666157943977.png

     

    Cheers !

  • Sn3l Profile Picture
    on at
    Re: Patch from Form Submit button to lookup field

    If I remove the .value There is no error, but if I select and submit.  Nothing happens 

     

  • Sn3l Profile Picture
    on at
    Re: Patch from Form Submit button to lookup field

    Hi. 

     

    Thank you for the response and help 

     

    On the Form on Success Property 

     

    Patch(
     'Suggested Travel',
     LookUp(
     'Suggested Travel',
     ID = LastSubmitID
     ),
     {BookingRef:DataCardValue9})

     

    If I add .value since this is a combobox

     

    I get the following error

     

    Sn3l_0-1666149878592.png

    GetRef it is refering to is BookingRef   ( I renamed the column in SharePoint but it kept this name in the List

     

    Sn3l_2-1666150089586.png

     

     

     

     

  • Anonymous_Hippo Profile Picture
    1,247 Super User 2024 Season 1 on at
    Re: Patch from Form Submit button to lookup field

    Hello @Sn3l ,

     

    Can you try this

    On the button for Submit/save for the form add this (replace with your form name)

     SubmitForm(FormName);
    Set(
     LastSubmitID,
     FormName.LastSubmit.ID
    );
    

     

    On your Form's OnSuccess Property add this

    Patch(
     'Suggested Travel',
     LookUp(
     'Suggested Travel',
     ID = LastSubmitID
     ),
     {
     BookingRef: DataCardValue9 //Here i think you need to add DatacardValue9.Text if it is a text field or DatacardValue9.Selected.Value if a combobox
    })
    
    
    
    

     

    Please note that Defaults is used to create a new record . Use patch to update an existing record

     

    Hope this helps 🙂

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,700 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,015 Most Valuable Professional

Leaderboard