SOLVED

Send an email when we assign a task in a list

Copper Contributor

Hi I'm trying to create a flow that sends an email to a user to let them know who is handling their enquiry. 

 

My Sharepoint list has a choice column called 'Status'. I want the flow to trigger when the choice selected is 'Assigned' but without an infinite loop of emails, so, once the email has been sent I also want to update the list item to change the status to 'in progress' instead.

 

However, it's still telling me there's an infinite loop in the flow checker. 

This is how my flow looks:

 

1. When an item is created or modified

2. Get user profile

3. Apply to each > Get item

4. Condition (if status = assigned send email)

5. Update item (with status value as 'in progress')

Any advice on what I'm doing wrong? 

 

14 Replies
best response confirmed by VSTrath (Copper Contributor)
Solution

@VSTrath yes you're flow will go into an infinite loop the way you have it. In my example below (prepared for a similar question) we are going to change the Status of the Bedar item below to Completed which will put in today's date in a different column, but it will not go into an infinite loop.

 

Important: the flow compares the current version of the list with the previous version so you must turn on list item versioning in your list settings.

 

0-SPList-Versioning.png

 

5-SPList-StatusChanged.png

 

In your flow do not use the when an item is created or modified trigger but use the SharePoint "when an item or a file is modified" and select your site and list:

 

1-Flow.png

 

Next, the first action should be the SharePoint  "get changes for an item or a file (properties only)". Again you select your site and list and then in the Since field add the following expression to get the changes since the previous version:

sub(int(triggerOutputs()?['body/{VersionNumber}']),1)

 

2-Flow.png

 

Next, add a condition and select Has Column Changed: Status is equal to true

 

3a-Flow.png

 

In my example we are also checking if the Status is now completed, so I've added aother line in the condition and selected Status value is equal to Completed. the reason it's status value and not just status is  because in my list the status column is a choice column.

 

3b-Flow.png

 

You can leave the red if no channel empty because we don't want anything to happen in that case. But in the green if yes channel add an "update item" action and add the utcNow() expression for today's date

4-Flow.png

 

 

6-SPList-Completed.png

 

In your scenario you would add the email action into the green if yes channel. And this flow avoids the infinite loop. 

 

Come back with any questions about this.

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User

Thanks @RobElliott - however I don't see these advanced options in the last step of adding the Update Item. This is what I get: 

 

Ah sorry ignore me - these appear once I put in the site address and list name. This is great! Will test it now. Many thanks for your reply.
OK so I tried it and still don't have the Completed field visible on the Update item step to add the utcNow expression. Do I need to create another column in my list for the time of completion or something?

@VSTrath  you must always have the columns in your list if you are going to use them in your flow. But remember to save your flow, close it and then go back into it as the list of columns in the update item action doesn't refresh dynamically.

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User

Worried that I'm now having a lot of columns that are only there to facilitate flows rather than useful for the users who will be referring to the list essentially as their dashboard. I know you can hide columns but is there a better way?

@VSTrath there are no columns that are only there just to facilitate the flow. Remember, I created this example to answer another question, you will have the columns you need so use those. There are no columns that I have that you need in order to run the flow, use your own columns. It was just an example.

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User

OK - thank you for your help Rob
One other thing - do you know how I add just a person's name rather than their whole MS profile into an email? I want to tell the user who has been assigned to their enquiry but the People choice column in my list uses their MS profile so I'm getting a long string of information appear in the email when it sends.

@VSTrath you'd need to add an Office 365 Users "get user profile (v2)" action, populate it from the people choice column from the dynamic content box then use Given name from the Office 365 Users section of the dynamic content box.

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User

I already have that for the recipient. Will it work to have two different ones?

@RobElliott - hm the flow is showing as complete but the email hasn't arrived in my inbox 

VSTrath_0-1632491563727.png

 

@VSTrath why do you have those apply to each controls in the green if yes channel? They are not needed and are causing your problem. The only action you need in there is the send an email action.

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User

@RobElliott - It created them automatically I think because I need to reference the category in the email body.

1 best response

Accepted Solutions
best response confirmed by VSTrath (Copper Contributor)
Solution

@VSTrath yes you're flow will go into an infinite loop the way you have it. In my example below (prepared for a similar question) we are going to change the Status of the Bedar item below to Completed which will put in today's date in a different column, but it will not go into an infinite loop.

 

Important: the flow compares the current version of the list with the previous version so you must turn on list item versioning in your list settings.

 

0-SPList-Versioning.png

 

5-SPList-StatusChanged.png

 

In your flow do not use the when an item is created or modified trigger but use the SharePoint "when an item or a file is modified" and select your site and list:

 

1-Flow.png

 

Next, the first action should be the SharePoint  "get changes for an item or a file (properties only)". Again you select your site and list and then in the Since field add the following expression to get the changes since the previous version:

sub(int(triggerOutputs()?['body/{VersionNumber}']),1)

 

2-Flow.png

 

Next, add a condition and select Has Column Changed: Status is equal to true

 

3a-Flow.png

 

In my example we are also checking if the Status is now completed, so I've added aother line in the condition and selected Status value is equal to Completed. the reason it's status value and not just status is  because in my list the status column is a choice column.

 

3b-Flow.png

 

You can leave the red if no channel empty because we don't want anything to happen in that case. But in the green if yes channel add an "update item" action and add the utcNow() expression for today's date

4-Flow.png

 

 

6-SPList-Completed.png

 

In your scenario you would add the email action into the green if yes channel. And this flow avoids the infinite loop. 

 

Come back with any questions about this.

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User

View solution in original post