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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Condition starts with ...
Power Automate
Unanswered

Condition starts with -- wildcard

(0) ShareShare
ReportReport
Posted on by

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

Categories:
I have the same question (0)
  • AlanPs1 Profile Picture
    2,471 on at

    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

     

  • Community Power Platform Member Profile Picture
    on at

    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 Profile Picture
    2,471 on at

    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

     

  • Community Power Platform Member Profile Picture
    on at

    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 Profile Picture
    2,471 on at

    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

     

  • Verified answer
    Community Power Platform Member Profile Picture
    on at

    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.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard