cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mousman85
Helper IV
Helper IV

Multi select/choices field populated via power automate

Hi All,

 

I've been looking for a solution for this issue and can't seem to find one. I'm using power automate to create a new record in my dataverse when a Form submission is received. Part of the form is a multiselect box where the user can choose the areas the supplier will work with. I need this to then populate the Multiselect/Choices field my dataverse table to use within a model driven app. 

 

I know that choice fields use a value when assigning using Power Automate. But I can't figure out how to reference each field get the correct value and then add that to a string that will then created the record. Is there a way to reference the choices column list out all the choices match them and then get the values? I've tried building it in Power Automate and creating an array with all the choices and values but when it tries to select it just returns all values in the array. 

 

Is there a better way to do this? 

11 REPLIES 11

Hi @mousman85 , @takolota , @ChrisPiasecki 

 

Did any of you receive an error message when trying to update the CDS/Dataverse multi select field with multiple values?  I keep getting an error message that the values I am providing are not valid integers.

 

To prevent the error message, I then created an array of valid integers:

This I created by using replace() to replace the labels of the user selected input from MSForm, with the corresponding multi select code (numeric) values.  After using replace() to remove all the quotes and square brackets, I split the resultant output into an array of numeric codes.  I then used int() to append to a second array - thus ensuring that the second array is one of only valid integers.  No error messages so all looking good and the output from a test run looks clean too.


Now I have to convert this array of integers into something that Dataverse will accept for the multi select field.   Have tried updating the multi select field with output from two compose functions using the integer array:

  1.  join(integer array,',') and
  2. concat(integer array)

Neither of these result in output which Dataverse will accept.  Here is the error message: 
         "The optionset values sent [948170000,948170001,948170002,948170003,948170004,948170005,948170006,948170008,948170010] are not valid integers."

 

Any ideas?  Can't find any solutions which work on any platforms.  

WendyLumsden
Advocate I
Advocate I

@mousman85 , @ChrisPiasecki,

 

I tried many options suggested on this Forum and only one solution worked for me in the case of a user submitting a MS Form with multi-select options (for Communication Channels in this case).  The requirement was to update a Dynamics solution table field or column with the all the options selected by the User.   

Here is the solution which ran successfully:

1. The first step was to replace all the labels selected by the user in the Form with the number values required for Dataverse:

replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(outputs('Get_response_details')?'body/r7f3e.........29fe8'], 'Facebook','948170000'),'Linked In','948170001'),'Instagram','948170002'),'Twitter','948170003'),'Newsletter','948170004'),'Blog','948170005'),'Website','948170006'),'Television','948170007'),'Radio','948170008'),'Other','948170009'),'Newspaper','948170010')
and then to replace all the resultant inverted commas which can probably be done in the same step as above but I like to keep things simple for clients to maintain:
replace(replace(replace(outputs('Replace_input_labels_with_multichoice_values'),'"',''),'[',''),']','')
2. The next step was to create an array of the resultant numbers (creating an array will allow you to work with each number seperately:
split(outputs('Clean_up_the_result'),',')
 3. The third step is to convert the string numbers to integers, which are required for updating Dataverse.  I had previously tried Join expression and a variety of other alternatives but the only one that ran successfully for multiple options was to loop through the array and within the loop use Append to string function with int() to create the input used for updating Dataverse.   The string I was appending to was a variable which is used to update Dataverse/Dynamics
concat(int(items('Apply_to_each')),',')
Concat is used to add the comma after each integer or choice value. 
4. The final steps are simple - just remove the comma at the end of the resultant variable by using length of variable, subtracting 1 from length and using substring function to provide the variable used to update Dataverse.
My flow looks like this:
WendyLumsden_0-1668521749739.pngWendyLumsden_1-1668521851025.png

 

 Please mark this is as a solution if it works for you or is helpful 🙂

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Users online (6,066)