cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Condition starts with -- wildcard

I would like to have a condition, with the value from a SPO metadata field NINO that startrs with **0 (where the ** are wildcards), to then go on to do what I need.

However it seems we cannot use wildcards with the "Starts with" option.

It seems like it should be so easy to get this to work.... but alas I am struggling a little.

If i change the ** to the first 2 characters of one of the NINO fields, it then works. 

Anyone know how I can make it do what i need?

Thanks!

 

ninoINT.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

I had some time away from this, but have resolved it in the end. Here is what was required:

 

We were expecting it to be 

substring(items('Apply_to_each')?['NINO'], 3, 9)

With the last 9 being the length of the source string. Actually, that number needs to be the number of charachters that you want in the outputted string. So I changed it to this, and it works as expected.

substring(items('Apply_to_each')?['NINO'], 2, 1)

 Thanks to anyone who offered help.

View solution in original post

6 REPLIES 6
AlanPs1
Resident Rockstar
Resident Rockstar

Hi @Anonymous , thank you for your post in the Flow Community.

I think to achieve what you asking, some use of substring will help . The example below assumes all the formats are the same length, although this could be enhanced further.

 

Here is my Flow to get you started, here are the input values and how I have siulated this approach.Capture-554.png

 

After simulating this with a manula trigger, I create an array that is in line with your values "**0"

 

createArray('XY01234', 'AB01234', '1201234')

Value 1 = 'XY01234'

 

Value 2 = 'AB01234'

Value 3 = '1201234'

 

The "Apply to each" iterates through the 3 values, then tests each on the condition.Capture-555.png

substring(items('Apply_To_Each_Array'), 3, 7)
starts with
string('0')

 Considering the below from the docs ...

substring('<text>', <startIndex>, <length>)
substring('hello world', 6, 5)
Parameter Required Type Description
<text> Yes String The string whose characters you want
<startIndex> Yes Integer A positive number equal to or greater than 0 that you want to use as the starting position or index value
<length> Yes Integer A positive number of characters that you want in the substring

 

This means it checks from the 3rd character on and if that starts with a 0 (zero).

 

Is this something like what you are looking for when applying the same logic to your own Flow?

Maybe try building this an see if does what you are looking for and report back.

 

If you have found my post helpful, please mark thumbs up.

 

Any other questions, just ask.

 

Thanks, Alan

 


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

Proud to be a Flownaut!


Anonymous
Not applicable

I was trying substrings initally, but it appears I did not understand the syntax. 

The length is the NINO will always be 9.

So where you entered the below, to get the string items from your array, any idea what I should be putting to get the output of the NINO metadata field? :

substring(items('Apply_To_Each_Array'), 3, 7)

 

I have been trying a few different things, for eg...

I was thinking it should be TriggerBody like this (which i summised from here😞

substring(triggerBody()?['NINO'], 2, 9)

I had expected it to retrieve the NINO from the Body, which I can see does have all the NINO fields listed, (as shown in this output from the failure message).

xmloutput.PNG

But this gave an error saying the field was NULL

errorflow.PNG

Any ideas what I should be putting?

Thanks again for your help.

 

AlanPs1
Resident Rockstar
Resident Rockstar

Hi @Anonymous  ... thanks for your reply.

 

Your "Apply to each" is called "Apply to each" to the below I would suspect. 

substring(items('Apply_To_Each'), 3, 9)

Your not using the trigger body as there are potentially multiple values hence it must come from "Apply to each".

 

Note: The 3rd value in your "NINO" is not a 0 (zero) ... this would mean if working, the value in your image will return false.

 

If you have found my post helpful, please mark thumbs up.

 

Any other questions, just ask.

 

Thanks, Alan

 


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

Proud to be a Flownaut!


Anonymous
Not applicable

Thanks for the reply Alan. My apologies, I had tried this yday with 

substring(items('Apply_To_Each'), 2, 9)

I also tried with a 3

substring(items('Apply_To_Each'), 3, 9)

I have now removed all other docs in the library, so the only doc in there contains a NINO that starts with SL0. So there should be no returns that are not correct. It still fails with a slightly different error to what we seeing, but the same error for when I used this "Apply to each" syntax yday:

InvalidTemplate. Unable to process template language expressions for action 'Condition' at line '1' and column '2620': 'The template language function 'substring' expects its first parameter 'string' to be a string. The provided value is of type 'Object'. Please see https://aka.ms/logicexpressions#substring for usage details.'.

 

I can see why your "Apply to each" would work on an array that only has a list of NINO numbers in it. As the flow will just step through those.

In my case, with the flow that looks like this, how does it know it needs to read the NINO field only? Where is that being stated?

ertert.PNG

And here you can see the doc library it is trying to get the field from:

ghjghj.PNGThanks again for your time!

AlanPs1
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

From what I can see, I expect it is this:

substring(items('Apply_to_each')?['NINO'], 3, 9)

assuming that NINO is at the root level

 

If you have found my post helpful, please mark thumbs up.

 

Any other questions, just ask.

 

Thanks, Alan

 


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

Proud to be a Flownaut!


Anonymous
Not applicable

I had some time away from this, but have resolved it in the end. Here is what was required:

 

We were expecting it to be 

substring(items('Apply_to_each')?['NINO'], 3, 9)

With the last 9 being the length of the source string. Actually, that number needs to be the number of charachters that you want in the outputted string. So I changed it to this, and it works as expected.

substring(items('Apply_to_each')?['NINO'], 2, 1)

 Thanks to anyone who offered help.

View solution in original post

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Users online (66,890)