Hllo
Hows it going ? Lockdown ? Yep me too. Bored ? Just a little bit.
I get these urges to write blog posts at the weirdest times. I woke up at 4:55am to the night time terror screams of my 4 year old and first thing I thought of, well after wondering what on Earth the racket was, was split and empty functions in power automate.
Yeah. I’m obsessed I know.
Do the SPLITS
Split is proper handy it lets you take a string and split it in two at a character of your choosing. I needed to pull a company name out of an email address so I pass the string through the split function and tell it where to split the text and hey presto !!
Lets look at this in more detail.
The string value is
We would like to get the “company” part out of this string. So watch split do it’s magic
It’s syntax is
Split( Text, Separator )
Split will return a string for each piece of text before and after the separator and output it as an array.
Here goes:
is going to give us an array of two items
{ ‘Jon.david‘,
‘Company.com’
}
We need the second part of this array so the above expression becomes
In this example the top string is [0] and the second part with company is [1]. This is it's index inside the array.
This will now give us the result
Next we need to pass that through a second split function to get the ‘company’ part of the string
which in a flow might look something like this
split(split(outputs('Get_response_details')?['body/reb5f5e283c3444a5ad7573f352087cb3'],'@')[1],'.')[0]
Without the [0] at the end we would have got
{ ‘company‘,
‘com’
}
So we then add the index at the end [0] to get ‘company‘
Wahoo. Broken down it looks like this:
The example is broken down into 3 compose steps.
First split - selects “company.com”
Second split - selects “company” from the array.
You can just jump to the "Compose: Do the SPLITS" action to do the whole thing in one compose step.
Now for Empty
What I needed to do here was take a form response and in one particular field, base a condition on whether there was any text entered or not.
All you need to do is wrap the string or forms dynamic field in empty() and it will respond with either a true or false.
In the condition step you say
True does not equal empty(form response)
That way, if the form field is empty it will return false. As true does not equal false the condition is satisfied and you are taken down the Yes path of the condition.
Thanks, have a good weekend, I'll try and get a lie in tomorrow!
Kommentare