Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Count string occurrences to trigger condition

(0) ShareShare
ReportReport
Posted on by 32

Hi Community,

 

I'm building a scheduled flow that assesses the most recent iAuditor inspections and only sends an email notification if a particular condition is met. The condition is True when a string occurs in the underlying iAuditor data x times or greater. Part of the complication is that the iAuditor Connector doesn't work with Repeat Sections, which is how the iAuditor form is constructed, so the Filter Array/ Compose combination detailed here can't do what I require. 

 

Currently the Flow looks like this (the Compose actions in red are where I have been attempting to count the output):

2022-09-26_095137.png

 

I can see from the Raw Output that it contains the string I'm looking for:

String existsString exists

 

I did experiment with creating an Initialize Variable action but it won't work inside an 'Apply to each', so I'm not sure if that is the right path to go down.

I've also played with building a 'length' expression, but with no luck so far.

 

If someone could provide a little assistance to get me past this hurdle I would be most appreciative.

  • Verified answer
    Courty Profile Picture
    32 on at
    Re: Count string occurrences to trigger condition

    Hi all,

     

    just communicating that this is now solved. I was able to get assistance from a programmer who found a workable solution.

     

    FWIW, he created a variable then used a combination of the skip, contains and indexOf functions to validate the presence of the string within a designated section of the output.

  • Courty Profile Picture
    32 on at
    Re: Count string occurrences to trigger condition

    I've done some more research and experimentation, and it appears that replicating the Python code is not possible as the specific output referenced is not available in Power Automate via the iAuditor connector. So the original query stands (an expression or similar to count occurrences of the string). Can anyone please assist?

  • Courty Profile Picture
    32 on at
    Re: Count string occurrences to trigger condition

    I don't know if this is useful or not, but the same outcome can be achieved in Zapier using the following Python code (I'm aware that Python can be used in Power Automate desktop, but I'm trying to keep that as a last resort for only if all else fails):

     

     

    auth_header = {'Authorization': 'redacted'}
    api_url = 'https://api.safetyculture.io/audits/'
    audit_id = input['audit_id']
    audit_doc = requests.get(api_url + audit_id, headers=auth_header).json()
    
    for item in audit_doc['items']:
     if item.get('responses') and item['responses'].get('failed') == True:
     return{'proceed': True}
    
    return{'proceed': False}

     

     

    So I'm making an assumption that an expression that replicates the query part of this code would solve my problem? 

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1