Forum Discussion
Flow update SharePoint list B based on Lookup column value in list A on Item Created
I'm having the same problem. I've tried using Compose, but I get stuck with an array, rather than just the value and I can't get any further. I feel like I'm nearly there, but can't make the final leap.
Posts/Pages I've tried to use as reference:
- https://powerusers.microsoft.com/t5/General-Flow-Discussion/How-to-filter-the-array-to-get-single-item/td-p/14981 (example of Compose)
- https://powerusers.microsoft.com/t5/Building-Flows/Get-access-to-single-element-of-array-outside-of-loop/td-p/34844 (My situation isn't a loop -- I don't think -- but thought it might lead somewhere)
- https://powerusers.microsoft.com/t5/Building-Flows/how-to-get-sharepoint-lookup-list-value-in-flow-email/td-p/11800 (the solution near the bottom looks like how I would expect it to work, but it's not working for me)
It also feels like we can't be the only people trying this. Anyone?
Jacques van der Hoven, I just figured it out using the hammer/machete approach. Someone please tell me there's an easier way. The basic issue is object v. value. The Dynamic Contents blocks are objects, but that Id field wants a value.
Setup: I have two training sessions lists: SessionList and SignupList. Anytime someone signs up for a session, I want to increment the 'Signups' field in the SessionList for the relevant session by 1, up to the max for that session.
Steps:
- Add a 'Condition' action after the "When a new item is created...' action (you'll delete it later)
- Select the ID field from the "When a new item..." as one of the condition parameters (it will appear in the dynamic content, assuming it's visible in your default view of that list -- why it won't appear directly in 'Get Item', I have no idea)
- Click the 'Edit in Advanced Mode' link at the bottom of the Condition action to see the code value for the item in question. In my example, the lookup field was Sessions: ID and the code was
@equals(triggerBody()?['Sessions_x003a_ID'], '')
So "Sessions_x003a_ID" = "Sessions: ID" - Copy the code for the field only. In my example:
triggerBody()?['Sessions_x003a_ID']
- Add the 'Get Item' action, select the relevant Site Address and List Name and past the copied code in the ID field AND add an '@' at the front AND wrap in doublequotes AND append the 'Value' parameter from the object in the format of "?['Value']", as here:
"@triggerBody()?['Sessions_x003a_ID']?['Value']"
- Delete the Condition from Step 1, save the flow, and your good to go.
NOTE: When you return to the Flow, the value in #5 will be converted to a Dynamic Element, but it still works. Again, why this doesn't seem to be available directly, is beyond me.
I've attached a screenshot of the final result in case that's helpful. The smaller image shows what a Condition's 'advanced mode' looks like (though it's for another field I was working with, so the values are different than the instructions above).
Hope this helps someone else.
As I said, there has to be a better way, but I've spent hours banging my head against this and found none. Would love better (actual?) documentation on this tool.
- Jerry WeeksJan 12, 2018Copper Contributor
Thanks - this got me started, in the end what worked - and for me was very easy was this, I found my lookup value came as a pair with its id, in this case "Channel ID", the value isn't in the list I trigger off, so SharePoint must store it hidden - revealed by Flows.
In my case I post on to a team channel webhook, but could just as easily update the "Channel" list.
- Bill BlaisJan 12, 2018Iron Contributor
Interesting. When you say 'came as a pair', how do you mean that? I'm probably missing something obvious, but do you have a screenshot showing this pairing?
- Jerry WeeksJan 12, 2018Copper Contributor
Both the altered list id, and the id of the list where I lookup for a value (Channel list) are shown:
So the pair in this case is the Channel list's "Title" and associated "Channel ID"