web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / SOLVED - Split at ONCE...
Power Automate
Answered

SOLVED - Split at ONCE several strings or when an item is created in multiple records on a new Sharepoint List considering empty values.

(0) ShareShare
ReportReport
Posted on by 23

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:

Untitled design (7).png

 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'.'."

 

Untitled design (4).png

The flow looks like:

 

 

3.png

5.png6.png7.png

 

Untitled design (8).png

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

 

11.png12.png

Categories:
I have the same question (0)
  • Verified answer
    DJ_Jamba Profile Picture
    2,837 Moderator on at

    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:

    DJ_Jamba_0-1713390857602.png

    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

  • eliotcole Profile Picture
    4,390 Moderator on at

    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:

    addProperty(
    	addProperty(
    		addProperty(
    			item(), 
    			'pallettesArr', 
    			split(
    				replace(
    					trim(item()?['LotPallet_x0023_']), 
    					' ', 
    					''
    				), 
    				'/'
    			)
    		),
    		'pallettesCountInt', 
    		length(
    			split(
    				replace(
    					trim(item()?['LotPallet_x0023_']), 
    					' ', 
    					''
    				), 
    				'/'
    			)
    		)
    	),
    	'hasPallettes', 
    	greater(
    		length(
    			split(
    				replace(
    					trim(item()?['LotPallet_x0023_']), 
    					' ', 
    					''
    				), 
    				'/'
    			)
    		), 
    		0
    	)
    )

    This will give you the following values on top of everything else:

    1. pallettesArr - An array of every pallette they listed
    2. pallettesCountInt - A count of the amount of pallettes they listed
    3. hasPallettes - Whether or not they have any pallettes to handle

    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
    @{items('ForEveryList2Item')?['hasPallettes']}
    is equal to
    @true

    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:

    @{items('ForEveryList2Item')?['pallettesArr']}
    If no

    Make a single item in List 2.

    You can hack around the empty fields either by inserting the following:

    @null

    ... 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. 🙂

  • Suggested answer
    takolota1 Profile Picture
    4,978 Moderator on at
    There is a way to split a column on delimiters to multiple records using only 6 actions & it will work for any number of records. And it will handle null / blank values in the split column.
    https://community.powerplatform.com/galleries/gallery-posts/?postid=b4b53bc0-0e9a-ef11-8a69-6045bdee0f9b

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 262 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 227

#3
Expiscornovus Profile Picture

Expiscornovus 225 Most Valuable Professional

Last 30 days Overall leaderboard