Unfortunately there is no intuitive way to update choice and lookup columns in SharePoint from PowerApps. The following should work if you disallow multiple selections for the column in SharePoint.
I will start with choice type columns, but the approach is exactly the same for lookups.
Let’s say your SharePoint list (MyList) has a choice column (MyChoiceColumn) with 3 choices: Choice A, Choice B, Choice C.
This works:
Patch( MyList, MyRecord, {MyChoiceColumn: { Value: "Choice A", '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"} } )
In order to make it practical, have a dropdown control (Dropdown1) in PowerApps with the following Items property:
Table( {Value: "Choice A"}, {Value: "Choice B"}, {Value: "Choice C"} )
Then you can modify the above Patch to this:
Patch( MyList, MyRecord, {MyChoiceColumn: { Value: Dropdown1.Selected.Value, '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"} } )
Now, for the case of lookup type columns. If you have a lookup to MyLookupList with MyLookupColumn, then set the Items property of the dropdown control to this:
MyLookupList
(you must have also added this list as a data source first)
Then the Patch will be this:
Patch( MyList, MyRecord, {MyLookupColumn: {Id: Dropdown1.Selected.ID, Value: Dropdown1.Selected.Title, '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"} } )
Please let me know if anyone has any issues with making this work.
I use:
Choices(DataSource.OData__Status) and that populates the choices in the drop down without issue. The above is based on SharePoint List set as DataSource, and choice field name d ‘_Status’, which in the datasource becomes ‘OData__Status’.
Works a treat
Thanks for the response.
For the moment (until/unless enumerating choice column values becomes an option) I’ll stick to using LookUp columns!
Say your choice column in SharePoint is *not* a lookup, but a straight forward set of choices hand entered into the column properties – do you know of a way of pulling the list of choices from SharePoint to populate the Drop Down’s choice properties?
Unfortunately I don’t think there is a direct method of enumerating the choices of a choice type column at the moment. I was under the impression that you could use the DataSourceInfo function for that as well, but reading the documentation and a quick test have not yielded any results. The only work-around would seem to do a Distinct(YourSpList, YourChoiceColumn.Value), but of course this will only yield those choices already used in the list and not the complete list of possible values. This will also be limited by delegation.
I also have this question, support for choices columns is seriously lacking in PowerApps