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 / Switch issue, Plus nev...
Power Automate
Unanswered

Switch issue, Plus never ending loop

(1) ShareShare
ReportReport
Posted on by 8
Hi,
 
We have a Sharepoint library where I'm trying to set up an approval system for new documents.
When a file is uploaded, the department value and file type defaults to a blank value. The user will then immediately select the correct department and file type and then I'm hoping to trigger a flow to direct the document to the correct approvals.
 
 
The flow did not seem to want to work properly, I keep getting an error for switch type null. So I added in a delay timer to hopefully give the user time to change the department type before the flow carries on. The null error does not appear again, but it can't seem to get past the check status step below. It also tries to run the loop multiple times even though I have only submitted one file to test the approval flow, so i am continuously getting approval requests on Teams until I cancel the flow test. What have I done wrong?
The switch has about 15 different branches so I will just show one branch (QA) below.
There is an email step after the set approval status that I haven't shown.
Hope that is enough information, I am banging my head against an imaginary wall. I am also pretty new to Power Automate so please do tell me if I have missed something glaringly simple. The below was working as a nested loop (so without the variable setting) until I found I needed more than 8 loops.
 
Regards
 
Marcy
 
 
 
 
 
Categories:
I have the same question (0)
  • Suggested answer
    Sayan Profile Picture
    818 Super User 2025 Season 2 on at
    Hey, are you using the Switch inside the Condition?
     
     
     
  • Suggested answer
    Sayan Profile Picture
    818 Super User 2025 Season 2 on at
    Hey,
     
    In your flow you have used "When a file is created or modified (properties only)" before the delay it does not mean that it will hold the updated value. As the Action runs before the update, so it holds only the value before update.
     
     
    In condition use the Value property of a Field like 
    triggerBody()?['ApprovalStatus']?['Value']
     
     
     
    For me switch is properly working.
     
     
     
     
     
    in switch use the Dynamic value of the Field from the Sharepoint.
     
     
    Hope it will solve the issue. If problem not solved, please let me know.
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If my suggestion helps you, gives it a Like and Marks as a Solution. Which motivates to solve more problems.
    Thanks,
    Sayan Patra
    RPA Developer
  • Suggested answer
    David_MA Profile Picture
    12,953 Super User 2025 Season 2 on at

    I am guessing that your switch is based on the department value. As soon as the document is uploaded, that is going to trigger your flow, which will be before the user sets the department value based on your description. I would add two trigger conditions to your flow. The first one will check to make sure the department field is filled and would be @not(empty(triggerBody()?['Department']))

    Since you are using the trigger when a file is created or modified, you probably don't want it triggering multiple times which will happen how it is currently configured once the document is created, again when the department field is set and a third time when the file type is selected.

    I am also going to guess that approval status has the default value of Pending. If so, I would base your second trigger condition off of that, but I would change the default value to something like New Document, Uploaded, etc.

    Then add a second trigger condition to check if the status is equal to your new default value. For example, @equals(triggerOutputs()?['body/Status/Value'],'Uploadded'). You can then set the status to Pending when your flow triggers so it will not trigger again during the approval.

    If you don't know what trigger conditions are, this is a good post on how to use them: 

    They are not the same as conditions within the flow but can be very powerful.

  • MarcyH Profile Picture
    8 on at
    @David_MA Thanks for that, I have added the 2 trigger conditions below. Now the flow will not recognise the starting action at all?
     
    I have turned on the content approval requirement for the library and there seems to be no option for me to use 'Uploaded' as a default status? I am happy to make it a custom column and use that as a trigger if that's how it has to be, but just want to check have I missed something silly.
     
  • MarcyH Profile Picture
    8 on at
    @Sayan Thanks. The switch is inside the condition 'Check Status-Pending'. I did use your suggested syntax inside the condition and it went straight to Terminate?

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 506 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 425 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard