Hello Community!
I am trying to build a flow in Power Automate to create new records from "List1" to "List2" in SharePoint. I have a column called "Pallet Tag", and this column can have multiple pallets - separates by "/" -, empty values or just one pallet recorded.
Visually, I want to following:
When I run the flow, I have this message:
"Unable to process template language expressions for action 'Condition' at line '0' and column '0': 'The template language function 'contains' expects its first argument 'collection' to be a dictionary (object), an array or a string. The provided value is of type 'Null'.'."
The flow looks like:
Thank you very much in advance,
Danie
UPDATE:
First of all, thank you very much @DJ_Jamba and @eliotcole. I used your ideas to solve the issue. I had two problems: first, getting all items and copying them with a new format to a new list, and second, copying each new item every time it was created. It was difficult for me, but now I have two different flows (one inactive to copy all the items just in the beginning, and then the second for real-time copy). I didn't know the split function was different for both, but finally, I have both formulas.
I am attaching them here in case someone needs this solution.
Cheers, Danie
Hi, @ddl3 ... I have a feeling that you may be better off using a few Select actions, here, to get this done without any loops.
I haven't built this, so I'm just spitballing.
You could perform a Select action and name it 'SelectList2Items' which has this in the Map field:
|
This will give you the following values on top of everything else:
Then if create an 'Apply to each' or 'For each' named 'ForEveryList2Item' on the newly made 'SelectList2Items' you can make the first action a condition based upon:
Left | Condition | Right |
|
is equal to |
|
Then for each of the branches you can do the following:
If yes |
Create an item in List 2 using another 'Apply to each'/'For each' action based on this value:
|
If no |
Make a single item in List 2. You can hack around the empty fields either by inserting the following:
... or you can use references to add the item using the 'Update item' hack I listed here, but just apply it to the 'Creat item' action instead. I'm sure it'll be fine. |
I'm a bit too tired to actually *do* this for you, but it should be sound. 🙂
Hi @ddl3
It looks like it's failing on the User2 record because there is no Pallet Tag and you can't split a null.
So based on your example:
When you are looping through List 1, your condition would be:
If Pallet Tag column is equal to null
Create item action (in the Yes block of the condition)
and only supply:
Record ID field
Date field
Created by Name field
Else (in the No block of the condition)
Another Apply to each action based on the split function against the Pallet Tag field.
Add a Create item action inside the 2nd loop which populates Record ID, Date, Created by Name and Pallet Tag from the first Apply to each loop
And Flow - Pallet Tag field is populated from the 2nd Apply to each loop