Update Multi Choice field in SharePoint from Canvas Application
In this post, we will see how can we update a Multi Choice field in SharePoint List from canvas application.
Since Multi Choice Field holds data in array, we cannot be able to update it directly how we do "Text Field" or "Number Field". So, to achieve this we can leverage ClearCollection to store the data and update it back to the SharePoint List.
Gallery Control : galTools
ClearCollection : colTeams (to store the multi choice data in the record)
In order to update the Multi Choice field - we are using PATCH function.
Scenario: We have a list of tools in a list and a multi choice field (Teams) which stores which team is using that tool. Any team can login to canvas app and update their team by clicking "Add" and "Remove" buttons in the gallery.
- If Team A using a tool and when it is no longer in user, then can click on "Remove" button. When Remove button is click we update Multi Choice by removing "Team A" from it.
- If Team B wants a tool to use, team can click on "Add" button. When Add button is click we update Multi Choice by adding "Team B" to it.
ClearCollect(colTeams,ThisItem.Teams);
Patch(colTeams,Defaults(colTeams),{Value:"Team A"});
Patch(Tools,LookUp(Tools,ID = galTools.Selected.ID),Defaults(Tools), {Teams:colTeams})
Comments
Post a Comment