cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
klaw-sha
Advocate II
Advocate II

Setting a multiple lookup column

We have a column in a list that allows for multiple lookups to another list.

 

I tried using the update's default ways first and explicitly providing the Id's. This, of course, worked without any problems

klaw-sha_1-1611164544059.png

 

So I tested it out and looked at the Run's result. This is what I see for that column:

klaw-sha_4-1611164786142.png

 

 

I then tried to manually create this json and put it in a compose. Apparently this kind of column only takes arrays, it doesn't take a string variable, but it can take a compose. I tried with the array but that did not work.

 

So I tried setting it with this manually written json. I used the exact same json from above but the result is just empty

klaw-sha_0-1611164469677.png

Here's the result:

klaw-sha_3-1611164709326.png

 

What's going on here?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @klaw-sha 

 

I was about to offer that option earlier then again I  want to see why this is not working. You can still map the final string value to an array. That might do the trick as well.

 

Thanks for letting me know and glad to hear that its working for you.

 

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

View solution in original post

10 REPLIES 10
abm
Super User
Super User

Hi @klaw-sha 

 

Could you show the steps how you construct the JSON?

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials
klaw-sha
Advocate II
Advocate II

I wanted to keep it simple at first and just tried copy and pasting the json instead of constructing it. Then once I confirm that works then move on to constructing it based off of dynamic data

Hi @klaw-sha 

 

In order to analyse further it would be good to see the steps you constructing (a screenshot).

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

Okay, i must have made a mistake before. But now copy and pasting directly into the compose action works.

klaw-sha_0-1611176770034.png

This is the result: 

klaw-sha_1-1611176864343.png

 

But then if I construct the string using dynamic content, it doesn't work. Here is what it looks like:

klaw-sha_2-1611176994651.png

Textually, we see the input is exactly the same, which is

[
  {
    "Id": 1
  },
  {
    "Id": 10
  }
]

 

Except I noticed that somehow the Id is appearing as red in the first way when I copied and pasted it into the compose. The second way where the string gets constructed, everything appears black. I wonder why.

 

This is how I construct the string

klaw-sha_4-1611177220560.png

I have an Apply to Each for all the values stored in an array variable (in this case, first value is 1 and the second value is 10). I have a variable called "comma", if the variable "counter" is greater than 0 then set "comma" to "," otherwise make it blank. Then set the variable "temp string" to the value of "update json" Then set "update json" to the value of temp string plus the [comma] {"Id": [Current Item] } attached to the end. Then increment the value of "counter" 

Then afterwards I add the square brackets before and after. The end result of all this is 

[
  {
    "Id": 1
  },
  {
    "Id": 10
  }
]

 

It seems okay to me! Any idea what I could be missing?

Hi @klaw-sha 

 

Thanks a lot for the detailed screenshot. It really helps to analyse the issue.

 

image.png

 

 

Above use the expression int() to convert the current item to integer.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

Hi @klaw-sha 

 

Also if the integer conversion doesn't work then add a compose and map the JSON string once it constructed. Finally add the output of compose for the update.

 

Let me know how it goes.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

Thanks for looking at my problem with me. I really appreciate it ❤️ 

 

Doing the int conversion on the current item did not help. I think ultimately, the web service just receives json string. Can you explain further what you mean about mapping the json? I don't know what that means. I searched json in the action search and only found "parse json" which i don't think is what we need here. And then I searched for map and only got options for Bing maps.

klaw-sha
Advocate II
Advocate II

Through more testing, I've found that it's the copying of the string from a Variable to the Compose action.

 

If I do this, then it works

klaw-sha_0-1611236469251.png

 

And when I do this it does NOT work

klaw-sha_1-1611236500392.png

 

Why would the two be different?? This is so frustrating!

After trying so many different things I figured out a solution. I created another variable as an array. I then set this array variable with the following expression: json(variables('update json')). Then I use this array variable in the update item action and it worked! Thank you to abm for trying so hard to understand and give me ideas on a solution. abm is truly a "super user"!

Hi @klaw-sha 

 

I was about to offer that option earlier then again I  want to see why this is not working. You can still map the final string value to an array. That might do the trick as well.

 

Thanks for letting me know and glad to hear that its working for you.

 

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Users online (4,119)