cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ian_C
Helper III
Helper III

New designer issue - Avoiding recursive loops

I have a basic workflow which relates to a Sharepoint list with one text field and one (single select) choice field.

The workflow consists of:
Sharepoint Trigger - When an item is created or modified

Get item - using id from trigger

Condition statement  - testing whether the "modified by email" was the system email account (under which I wrote the workflow)

If true then terminate

If false then update item

  

Prior to the new designer layout I have written all my workflows to test the "Modified by email"  to avoid recursive loops and terminate the workflows and everything was fine, I could test the "Modified by in either the trigger or the Get item action. No problem.

 

However in the new designer world If I add a Get item action under the trigger it immediately wraps it in a "For each" loop, my condition statement then causes the workflow to fail with : 
'The template language expression 'body('Get_item')?['Editor']?['Email']' cannot be evaluated because property 'Editor' cannot be selected. Array elements can only be selected using an integer index.

Alternatively if I point my condition statement to the modified by email field trigger then the designer encapsulates that into a for each loop and I can't subsequently have a terminate statement inside that.

I have tried switching to classic designer and it does exactly the same thing. 
What has changed and how do we now go about avoiding recursive loops?

 

Many thanks

15 REPLIES 15

Try this as the expression in your condition. No need to "Get Item". 

 

triggerOutputs()?['body/value'][0]?['Editor/Email']

 

Rhiassuring_0-1701809269505.png

 

 

Or,  you could just use it as a trigger condition (available through the Settings in the Trigger) and forego the condition in the flow entirely: 

 

@not(equals(triggerBody()?['value'][0]?['Editor/email'],'rhia@email.com'))

 

This means it will only run if the Modified By is NOT "rhia@email.com".

 

______________________________________________________________


Did this answer your question? Please mark it as the solution.
Did it contribute positively towards finding the final solution? Please give it a thumbs up.

I answer questions on the forum for 2-3 hours every Thursday!



If one of @Rhiassuring's suggestions does not work, you can switch to the old designer by clicking on the three dots at the top-right of the screen:

David_MA_0-1701810207259.png

Of course, I don't know how long this will be allowed until we're all forced to use the new designer. Are you enjoying the new designer? It seems like a step backward to me.

@Ian_C Why do you need to use a "Get Item" action? The outputs should be the same for the trigger as the Get Item. Seems to be redundant.

Doesn't solve your apply to each issue, but curious about needing to use Get Item.

@wskinnermctc Hi, I used the "Get item" action on occasion where I've needed to change the trigger, plus it also makes for easier visual debugging.

@Rhiassuring Thanks I'll give this a go and report back

 

@David_MA Thanks I tried switching back using the three dots however this still had the same effect. 
It's like the Sharepoint Trigger - When an item is created or modified and the  Get item action - using id from the trigger are returning arrays rather than the single item.

That was happening to me as well (wanted to see what would happen if I switched with that flow.) I think you'd need to build it from scratch in Classic to not experience the weird "get item" situation.

______________________________________________________________


Did this answer your question? Please mark it as the solution.
Did it contribute positively towards finding the final solution? Please give it a thumbs up.

I answer questions on the forum for 2-3 hours every Thursday!



@Rhiassuring Thanks, the option to build from classic seems to be no longer available, selecting create automatically starts the new designer

 

Thanks @Rhiassuring  your code in the condition works so I can stop the recursive loops. 

I tried putting your code into the trigger settings so that I wouldn't need the condition check 

and it fails with 
Unable to process template language expressions for action 'Condition' at line '0' and column '0': 'The template language expression 'triggerOutputs()?['body/value'][0]?['Editor/Email']' cannot be evaluated because property '0' cannot be selected.

 

This seems to indicate that the trigger is not returning an array however if you do a subsequent "Get Item" or "Update Item" referencing the ID from the trigger it puts the action within a "For each" loop - Most odd.

 

 

Hi @Ian_C  - note that the formulas I posted are for 2 different scenarios. One for if you continue to use a condition, and one for if you user the trigger condition.

 

The trigger formula is this one:  

 

@not(equals(triggerBody()?['value'][0]?['Editor/email'],'rhia@email.com'))

 

I've just double checked, and it's valid but what I have found, is that you can't "test" for it.

 

Like, if you set the trigger condition and then click "Test" and Automatically or Manual, it won't operate correctly. (Which I think is another thing that has changed lately, as I swear I used to test trigger conditions manually all the time..)

Save it, and go modify something in the library, and see if it runs. In my circumstance, it didn't run when I edited an item as myself, but it did run when Tom Hanks edited the item.

______________________________________________________________


Did this answer your question? Please mark it as the solution.
Did it contribute positively towards finding the final solution? Please give it a thumbs up.

I answer questions on the forum for 2-3 hours every Thursday!



Thanks @Rhiassuring I understand about the scenarios. The code for the condition statement (after the trigger) works absolutely fine. (Though I still have superfluous for each loops around any further actions which reference the id in the trigger). 

 

On the other scenario I pasted the code exactly as stated (but with my email) into the actual trigger condition in the settings on the trigger. Then went to the list and added a new entry. Returning to the Flow summary screen (see below) it reported an error with the flow trigger however still ran the flow and then the flow ran again (due to there being an update item action), ignored the trigger condition and was thrown out by the condition statement after the trigger.

So it basically ignored the condition within trigger settings

Ian_C_0-1701939998680.png

Looking at the flow checker it just says there is a problem with the trigger with a link to the trigger which takes me to a blank screen.


Well that's.. totally bizarre. I'm sorry that's happening. I've now tested my trigger condition twice, with the same outcome both times ... which isn't what you're getting at all! 

@wskinnermctc @ScottShearer @David_MA   any thoughts?

______________________________________________________________


Did this answer your question? Please mark it as the solution.
Did it contribute positively towards finding the final solution? Please give it a thumbs up.

I answer questions on the forum for 2-3 hours every Thursday!



This is kind of ridiculous, but I have found a difference depending on how the trigger is created. And/Or if you click Save.

 

I think the problem has to do with the "Done" button that no longer exists in the action settings. In classic view, you had to click Done when changing settings on an action. In Co-Pilot, you just switch between tabs so the flow doesn't really recognize the settings change.

 

So combine the issue of needing to turn on "Split On" when you have the trigger created automatically along with not having an Done button, the flow doesn't recognize the change.

 

Basic Solution 1:

  • Create Brand New Flow with trigger "When an item is created or modified"
  • Go to the Trigger settings, you need to turn the "Split On" to On and use the dropdown to select body/value.
  • Then add a Compose step and type any text in the field so it's not empty.
  • Then click Save

Now the dynamic content is available and does not cause an For Each.

 

Basic Solution 2:

  • Create Brand New Flow with trigger "When an item is created or modified"
  • Delete the Trigger
  • Re-Add the trigger "When an item is created or modified"

The Split On is automatically turned on when you manually create the trigger. The dynamic content is available and does not cause a For Each.

 

This is really silly

Omg, really? That's a great catch if that's the case, @wskinnermctc 

 

The new designer and all the changes lately make it really difficult to pinpoint things. I'll look forward to seeing if your recommendation works for  Ian.

______________________________________________________________


Did this answer your question? Please mark it as the solution.
Did it contribute positively towards finding the final solution? Please give it a thumbs up.

I answer questions on the forum for 2-3 hours every Thursday!



Ian_C
Helper III
Helper III

Hi @wskinnermctc , @Rhiassuring ,
I've tried both the Basic solution 1 and 2 and yes they both work in that they do not create the needless for each loops around a Get item or Update item action. 

It's odd though that you would need to use the "split on" for the trigger as the trigger action should only be actioning one item and not an array (as i understand it the Split-on would cause a separate workflow instance for each item in hte array if there were any).
Surely the trigger "When an item is created or modified" should not be referencing an array in the first place. 

Also it seems now that over this weekend the three dots in the top right hand corner has now changed to a toggle switch now enabling the creation of a workflow and immediately switching back to classic mode. 

The trigger action pre

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (1,837)