Update SharePoint Lookup Field (multiple values allowed) from standalone Power App

Problem:

It may turn tricky to update SharePoint items from a standalone Power App, if you’ve configured a SP lookup column to allow multiple values.

Solution:

All you need to get around that issue, is to add another ComboBox to the datacard in the Power App form.
Then also create a data connection to the list, where the lookup values reside.

Settings for the ComboBox:

DefaultSelectedItems: If(Not(IsBlankOrError(Parent.Default)),Parent.Default)

OnChange: ClearCollect(myCol,ForAll(ComboBox1.SelectedItems,{Id: ThisRecord.ID,Value:ThisRecord.Title}));Reset(DataCardValue3)

OnSelect: Clear(myCol)

Settings for the origin lookup dropdown:

Change the setting for “multiple selections allowed” to “true”

DefaultSelectedItems: If(Not(IsBlank(Parent.Default)) && IsEmpty(myCol),Parent.Default,myCol)

(myCol = the collection created in the ComboBox OnChange property)

Explanation:

  • First we check, if there are already values available in the source item
  • the OnChange makes sure, that whenever we select new items, the collection myCol will be updated accordingly
  • the Reset() makes sure, that the values in the origin dropdown will also be updated
  • the Clear() function resets the collection, when the user starts a new selection
  • the origin dropdown will always have the selected items from the ComboBox
  • last but not least, hide the origin dropdown and that’s it

One more important thing to mention!
Keep the “Update” property of the datacard as “DataCardValuexx.SelectedItems” – if you try to pass in a table, the submit form function will fail. That’s the trick here.

Enjoy!

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...