web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch Both LookUp and ...
Power Apps
Answered

Patch Both LookUp and Attachments to SharePoint. Only one or the other works, not both.

(0) ShareShare
ReportReport
Posted on by 139

Issue: Unable to Patch SharePoint Site with both LookUp values AND Attachments.  Only one, or the other works, but not both. 

 

Everything in the code below, works to Patch my Lookup fields in SharePoint from the PowerApps Form:

 

SharePointIntegation > OnSave

 

 

Patch('SPList',
 Defaults('SPLIst'),

 Column1: textbox.Text,
 Column2: textbox.Text,
 Column3: {
 '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
 Id: combobox1.Selected.ID,
 Value: combobox2.Selected.Title
 },
 Column4: {
 '@odata.type': #Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
 Id: ddVehicle.Selected.Id,
 Value: ddVehicle.Selected.Value
 },
 );
 ResetForm(SharePointForm1); 
 RequestHide() 

 

 

I found this thread here, and the suggestion worked to add the attachments to the SharePoint item BUT, now the LookUp columns are empty:

 

 

 SharePointForm1.Updates

 

 

Here is the final version of the code I'm using

 

 

Patch('SPList',
 Defaults('SPLIst'),

 Column1: textbox.Text,
 Column2: textbox.Text,
 Column3: {
 '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
 Id: combobox1.Selected.ID,
 Value: combobox2.Selected.Title
 },
 Column4: {
 '@odata.type': #Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
 Id: ddVehicle.Selected.Id,
 Value: ddVehicle.Selected.Value
 },
 SharePointForm1.Updates
 );
 ResetForm(SharePointForm1); 
 RequestHide() 

 

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    156,425 Most Valuable Professional on at

    Hi @stayinginsync ,

    Try the other way around - you also have Id instead of ID and you do not need the odata reference any more

    Patch(
     'SPList',
     Defaults('SPList'),
     SharePointForm1.Updates
     Column1: textbox.Text,
     Column2: textbox.Text,
     Column3: 
     {
     Id: combobox1.Selected.ID,
     Value: combobox2.Selected.Title
     },
     Column4: {
     Id: ddVehicle.Selected.ID,
     Value: ddVehicle.Selected.Value
     },
    );
    ResetForm(SharePointForm1); 
    RequestHide()

    I am also assuming here that both combo boxes have Items of

    Choices(SPList.LookupFieldName)

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

     

  • stayinginsync Profile Picture
    139 on at

    @WarrenBelz 

     

    Item #1 - Thanks for the feedback.  That worked.  

     

    Item #2 - the "dd" is a dropdown, not a combobox.  If I change it from Id to ID, the whole thing goes red.

     

    Item #3 - To answer your question,  no I'm not using Choices, because I get this error: stayinginsync_0-1647801786167.png

    This may, or may not, help.  The code is part of a cascading drop-down list.

     

    • ComboBox1.Items = 

     

     

    Sort(SPList,SPLookupColumn1,Ascending)

     

     

    • ComboBox2.Items = 

     

     

    SortByColumns(Filter(SPList2, SPLookupColumn1 = combobox1.Selected.Title),"Title",SortOrder.Ascending)

     

     

    • Textbox1
    • Textbox2

     

     

    Concatenate(combobox1.Selected.field_1," ", combobox2.Selected.field_3," ", Textbox1.Text)

     

     

    It works, but if there is a good reason I should use "Choices" instead of this, I'm open to hearing it, and suggestions on how to fix the implementation for improvement.

     

    Item #4 - And, if I may ask a follow-up, this is great for the SharePointFormIntegration.OnSave, but I cannot figure out what to put in the OnView and OnEdit to display the Lookup items selected in SharePoint.   Do I need to do some kind of a reverse Patch(); ???  {{if you need me to create a new post for this item so I can resolve item #1, and then you get credit for solving items 3 & 4 separately, I'd be happy to do so, just let me know}}

     

    • OnView & OnEdit are using:

     

     

    Set( selectedItem,
     SharePointIntegration.Selected );

     

     

     

    Thanks in advance.

    Twitter - @technomensch

  • WarrenBelz Profile Picture
    156,425 Most Valuable Professional on at

    Hi @stayinginsync ,

    #1 - good to see it works as this was the question you posted

    #2 - if it works, leave it alone (I  could not see your data)

    #3 - as above and was just making a likely assumption - what you have does not suit Choices()

    #4 - this should resolve on the form (the Lookup in the control) - what is it you are trying to do that is not working ?

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • stayinginsync Profile Picture
    139 on at

    @WarrenBelz 

     

    When I select the item from my SharePoint list, and hit EDIT, or click on it to view, the two comboboxes are not populated by the LookUp values.  The comboboxes are empty.  When I say empty, I mean they are not populated with the data written to the column when the new item was saved.  The other fields, however, are populated as expected.

     

    Thank you in advance.

    Twitter- @technomensch.

  • WarrenBelz Profile Picture
    156,425 Most Valuable Professional on at

    Hi @stayinginsync ,

    Please supply (in Text) for the two Combo Boxes

    • The Items of the two Combo Boxes
    • The DefaultSelectedItems of these
    • The name and type of field it is writing to

     

  • stayinginsync Profile Picture
    139 on at

    @WarrenBelz 

     

    SPList1 = SPLookupColumn1 (Text Column on SharePoint)

    SpList2 = SPLookupColumnA (Text Column on SharePoint)

     

    • ComboBox1 (Items)
    Sort(SPList1,SPLookupColumn1,Ascending)
    • ComboBox1 (DefaultSelectedItems)
    Parent.Default
    • CombBox2 (Items)
    SortByColumns(Filter(SPList2, SPLookupColumnA = combobox1.Selected.Title),"Title",SortOrder.Ascending)
    • CombBox2 (DefaultSelectedItems)
    Parent.Default

     

  • Verified answer
    WarrenBelz Profile Picture
    156,425 Most Valuable Professional on at

    Hi @stayinginsync ,

    In the DefaultSelectedItems, try the following

    ComboBox1

    {SPLookupColumn1:ThisItem.SPLookupColumn1}

    ComboBox2

    {Title:ThisItem.SPLookupColumnA}
    

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • stayinginsync Profile Picture
    139 on at

    @WarrenBelz 

     

    Thanks.  I had it working ONCE.  (One of the few things I hate about this feature is there is no revision history to revert back to).  Then I tried to make some additional changes to see if I could also leverage the ViewForm to make just the View ReadOnly, but now I broke both and can't get them to work again.  Can you verify which of the following the SharePointIntegration OnEdit and OnView should be:

     

    • Option #1

     

    Set( selectedItem,
     SharePointIntegration.Selected );

     

     

    • Option #2 - OnView

     

    Set( selectedItem,
     SharePointIntegration.Selected );
    ViewForm(SharePointForm1);

     

     

    • Option #2 - OnEdit

     

    Set( selectedItem,
     SharePointIntegration.Selected );
    EditForm(SharePointForm1);

     

     

    • Option #3 - OnView

     

    ViewForm(SharePointForm1);
    Set( selectedItem,
     SharePointIntegration.Selected );

     

     

    • Option #3 - OnEdit

     

    EditForm(SharePointForm1);
    Set( selectedItem,
     SharePointIntegration.Selected );

     

     

    • Option #4 - OnView
    Set( selectedItem,
     SharePointIntegration.Selected );
    SharePointForm1.DisplayMode.View;

     

    • Option #4 - OnEdit
    Set( selectedItem,
     SharePointIntegration.Selected );
    SharePointForm1.DisplayMode.Edit;

     

    And that combobox1.Default and comboBox2.Default (not DefaultSelectedItems) should be

     

    • Option #1

     

    Parent.Default

     

     or

    • Option #2

     

    ThisItem.SPList

     

     

    Thanks in advance.

  • WarrenBelz Profile Picture
    156,425 Most Valuable Professional on at

    @stayinginsync ,

    The Default in Combo Boxes does nothing (I am not sure why it is there) - to display the required value, it needs to be in DefaultSelectedItems - did you try the suggestions I posted?

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

     

     

  • stayinginsync Profile Picture
    139 on at

    @WarrenBelz 

     

    Yes, I tried the suggestion but it did not work.

     

    Screen Shot 2022-03-23 at 9.57.25 AM.png

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 345 Most Valuable Professional

#2
11manish Profile Picture

11manish 207 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 177

Last 30 days Overall leaderboard