cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
aboucher
Level: Powered On

Patch combobox to SharePoint list

Hello,

 

I am trying to patch a Combobox to a SharePoint list.  The combo box has a list of values from a SharePoint list.  I got it so it does not throw errors in the compiler, but it just does not patch.  After I run the code, the Destination field is blank.

Patch(
            tblPass,
            {Destination: cboDestination})
1 ACCEPTED SOLUTION

Accepted Solutions
aboucher
Level: Powered On

Re: Patch combobox to SharePoint list

Well, I got it to work.  I ended up just using cboDestination.selected.

View solution in original post

10 REPLIES 10
Super User
Super User

Re: Patch combobox to SharePoint list

Hey @aboucher, you are close! There is one property missing from your Patch statement: the Base Record. In between your data source and the record to be changed you need something to tell the Patch statement what to patch, either a new record or updating an existing one.

 

Also, your reference to the combo box isn't fully qualified to reference the item you are trying to patch. It is instead referencing the control. To reference the selected value, you would have:

cboDestination.Selected.*Value*

where *Value* is the name of the field you are wanting to patch.

 

To create a new record, you would use the Defaults function like so:

// Patch a new record
Patch(
    tblPass,
    Defaults(tblPass),
    {Destination: cboDestination.Selected.*Value*}
)

 

To update a record, you would need something that identifies the specific record you are trying to change. Using a LookUp is one nice way but you could also reference a selected item in a gallery or some similar technique. I'd be happy to help out with the specifics of that if you would like but here are some examples:

// Patch an existing record with LookUp
Patch(
    tblPass,
    LookUp(tblPass, ID = varItemID),
    {Destination: cboDestination.Selected.*Value*}
)

// Patch an existing record with a gallery item
Patch(
    tblPass,
    Gallery.Selected,
    {Destination: cboDestination.Selected.*Value*}
)

The important aspect is that it needs to be a Record (i.e. row of the table) that is referenced.

 

I hope that gets you going with your Patch statement! Please let me know if I can clarify or offer further assistance!

aboucher
Level: Powered On

Re: Patch combobox to SharePoint list


@wyotim wrote:

Hey @aboucher, you are close! There is one property missing from your Patch statement: the Base Record. In between your data source and the record to be changed you need something to tell the Patch statement what to patch, either a new record or updating an existing one.

 

Also, your reference to the combo box isn't fully qualified to reference the item you are trying to patch. It is instead referencing the control. To reference the selected value, you would have:

cboDestination.Selected.*Value*

where *Value* is the name of the field you are wanting to patch.

 

To create a new record, you would use the Defaults function like so:

// Patch a new record
Patch(
    tblPass,
    Defaults(tblPass),
    {Destination: cboDestination.Selected.*Value*}
)

 

To update a record, you would need something that identifies the specific record you are trying to change. Using a LookUp is one nice way but you could also reference a selected item in a gallery or some similar technique. I'd be happy to help out with the specifics of that if you would like but here are some examples:

// Patch an existing record with LookUp
Patch(
    tblPass,
    LookUp(tblPass, ID = varItemID),
    {Destination: cboDestination.Selected.*Value*}
)

// Patch an existing record with a gallery item
Patch(
    tblPass,
    Gallery.Selected,
    {Destination: cboDestination.Selected.*Value*}
)

The important aspect is that it needs to be a Record (i.e. row of the table) that is referenced.

 

I hope that gets you going with your Patch statement! Please let me know if I can clarify or offer further assistance!


Hello @wyotim, thanks for the replay.

 

I am a little confused on the Selected.*Value*.  Isn't the name of the field "Destination"? Or am I way off base when you say "Field".  

I am using the patch to create a new record.  

DMumbai
Level: Powered On

Re: Patch combobox to SharePoint list

For whatever reasons .. creating new records stops working for me. Does it give


@aboucher wrote:

@wyotim wrote:

Hey @aboucher, you are close! There is one property missing from your Patch statement: the Base Record. In between your data source and the record to be changed you need something to tell the Patch statement what to patch, either a new record or updating an existing one.

 

Also, your reference to the combo box isn't fully qualified to reference the item you are trying to patch. It is instead referencing the control. To reference the selected value, you would have:

cboDestination.Selected.*Value*

where *Value* is the name of the field you are wanting to patch.

 

To create a new record, you would use the Defaults function like so:

// Patch a new record
Patch(
    tblPass,
    Defaults(tblPass),
    {Destination: cboDestination.Selected.*Value*}
)

 

To update a record, you would need something that identifies the specific record you are trying to change. Using a LookUp is one nice way but you could also reference a selected item in a gallery or some similar technique. I'd be happy to help out with the specifics of that if you would like but here are some examples:

// Patch an existing record with LookUp
Patch(
    tblPass,
    LookUp(tblPass, ID = varItemID),
    {Destination: cboDestination.Selected.*Value*}
)

// Patch an existing record with a gallery item
Patch(
    tblPass,
    Gallery.Selected,
    {Destination: cboDestination.Selected.*Value*}
)

The important aspect is that it needs to be a Record (i.e. row of the table) that is referenced.

 

I hope that gets you going with your Patch statement! Please let me know if I can clarify or offer further assistance!


Hello @wyotim, thanks for the replay.

 

I am a little confused on the Selected.*Value*.  Isn't the name of the field "Destination"? Or am I way off base when you say "Field".  

I am using the patch to create a new record.  



a random error about "field missing" Anyone having the same issue?

Super User
Super User

Re: Patch combobox to SharePoint list

Hey @aboucher, apologies for the ambiguity!

 

It very well could be Destination but it depends on how your combo box is set up. For instance, if your combo box is set up to show distinct values in a table it could be Result as that is what PowerApps names a column that results from a Distinct formula. It could be Value if you hard-coded some items into the combo box. If you connected a table to the combo box, you would use the name of the field you are after, such as Destination.

 

I am guessing that the last one is the scenario you are using, so Destination would probably be the field you are after. Without knowing your particular situation I was trying to keep it open and avoid confusion but I didn't do too well I guess! Smiley Very Happy Let me know if that sorts things out or if I can try to help out further!

 

 

Super User
Super User

Re: Patch combobox to SharePoint list

@DMumbai, I would check to see if there is a required field that you aren't patching as that is usually the case with that error, at least in my experience. It can be a bit tough to sort out because it doesn't tell what field is missing. I would go to the data source and see what fields are required, if any, and compare that to your Patch statement. Feel free to reply with more info if you would like; I'd be happy to try and help out!

cwebb365
Level 10

Re: Patch combobox to SharePoint list

First question is, what is the data type of the column in SharePoint, that will determine how you patch it.
cwebb365
Level 10

Re: Patch combobox to SharePoint list

I have a lookup column in this example, but I beleive the same would work for a Choice column. Anyway, I collect the changes in the combobox into a collection, then loop the collection to add the values. It's fairly Simple once you have this info :). 

 

So on button click I have this at the top:

ClearCollect(SelectedLocations,drp_AccountingLocation.SelectedItems);

then the patch after. and for the "Location:" column, I use the ForAll to loop through that collection and add the values. 

Location: ForAll(SelectedLocations,{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id:ID,
Value:Title})

 

But I also use this method because I customize the display name used in the drop downs to a different value. If you don't do that, I think you can just use something like this in patch. 

 

Location: combobox.SelectedItems 

 

Should be all you need. 

Community Support Team
Community Support Team

Re: Patch combobox to SharePoint list

Hi @aboucher ,

Could you tell me

1)the setting of the combo box's Items?

2)the data type of Destination field?

Firstly, the right syntax of Patch a new record should be like this:

Patch(
            tblPass,
Defaults(tblPass), {Destination: ....})

Secondly, how to patch Destination field is decided about the two questions that I asked.

Thirdly, as @wyotim  said, do you have any required field?

If you have, you should patch with this field's value, or else the patch function will not work.

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
aboucher
Level: Powered On

Re: Patch combobox to SharePoint list

The choices in the list are coming from the choices setup in Sharepoint.  It also allows for fill-ins.  Below is the screenshot of the settings of this column of the Sharepoint list.  I ran into issues with required fields earlier on in the development of this, so now there are no required fields.

Capture.PNG

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,687)