Categories
Office 365 Power Automate Sharepoint Tips

Power Automate SharePoint Update Loop

“Actions in this flow may result in an infinite trigger loop” when updating the same list item on the “When an item is created or modified” trigger.

In this scenario, Power Automate will enter an infinite loop as the actions in the flow trigger a new instance of the flow. SharePoint Designer workflows internally prevented this scenario so this guide will explain how to achieve the same in Microsoft Power Automate.

To prevent an infinite loop, we create a specific user context to run the PowerAutomate updates on the list item, then we add a trigger filter to prevent new flows from starting when started by the Power Automate user.

First, add a user in the Office 365 Admin Centre

For the purpose of this example, I will call the user Power Automate.

Then the user needs to be assigned a Power Automate license (a free license is fine for many environments) and the relevant permissions on the SharePoint site that the flow will be running on.

Then you want to assign the “Update item” action to the new user you have created.

At this point, it’s worth saving and testing your flow and letting at least 2 iterations of the loop cycle through before stopping it and opening the second iteration. You will want to open and check the output.

In this scenario, I haven’t purchased an exchange license for the user so I don’t have a value for body/Editor/Email which would be preferable, so I will use body/Editor/DisplayName

"Editor":{"@odata.type":"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser","Claims":"i:0#.f|membership|powerautomate@devpros.com.au","DisplayName":"Power Automate","Email":null,"Picture":null, "Department":null,"JobTitle":null}

Now that we have targeted the element we are identifying, let’s create the trigger condition by editing the settings on the flow trigger.

We will create a trigger condition and enter the expression to check if the user who modified the item was the Power Automate user we created and assigned to the step.

@not(equals(triggerOutputs()?['body/Editor/DisplayName'],'Power Automate'))

This would read in English as; The trigger output value extracted from body/editor/displayname is not equal to ‘Power Automate’

The result of this condition should be true for the flow to initialise.

Once you save and turn your flow back on, upon testing you should see each time a list item is updated, a single instance of the flow run.

Optional

If you don’t observe the desired outcome, I would recommend creating a couple of steps in your workflow to check the output of the expression.

First, check the output of the desired field by initialising a variable (initialize variable).

triggerOutputs()?['body/Editor/DisplayName']

Then check the output of your boolean condition by initialising another variable (initialize variable).

not(equals(triggerOutputs()?['body/Editor/DisplayName'],'Power Automate'))

Save and turn the flow back on. Update the list item and once at least 2 iterations have passed, stop the flow and check the second iteration.

This is the expected result, we can see the value of DisplayName is ‘Power Automate’ and the expression is false, which means with the trigger filter added, it will not run on this trigger. This information should assist you with troubleshooting the issue.

Categories
Sharepoint

Sharing Information has Never been Easier!

Covid-19 hit and the world as we know it changed. Many people that were used to the daily commute to the office and the 9-5 routine were now working from home, and the sharing of information became more vital than ever.

Many companies were not prepared technologically for having a remote workforce, but as we have with everything Covid-19 related, slowly people adapt to the new normal.

The free flow of information within businesses increases productivity; Devpro understand that your business is unique, so we take the time to get to know your business, so we can provide a tailored solution for you.

Devpro have been instrumental in providing many businesses with a centralised system for staff to share information through SharePoint.

What is SharePoint?

SharePoint is a Microsoft tool that manages your documents and enables staff to collaborate on work remotely, together. SharePoint is a great way to give your organisation a centralised data-sharing system.

Why is SharePoint integral to a Business?

SharePoint can provide your employees with a centralised database and system, providing they have access to a web-browser.

SharePoint gives your organisation easy access to data, cutting down on paper documents, and streamlining the free flow of data.

Sharing documents has never been easier and more transparent; no more emailing large files back and forth, SharePoint gives you the perfect platform to share data and communicate feedback. 

SharePoint’s alerts can help you organise your day and remind you to meet those important deadlines.

SharePoint allows you to restrict access of sensitive documents, so you can control the flow of data throughout your organisation.

With the right guidance and set-up from Devpro we can customise your organisation’s SharePoint to perform to your companies’ needs. We tailor your centralised system to suit you, so your SharePoint becomes a valuable tool not a clunky CRM.

Contact your SharePoint Specialists today

Devpro are the specialists in SharePoint; we can develop the most efficient system for your company and provide full and thorough training so you and your staff can maximise its capabilities and improve your company’s efficiency. Devpro in Byron Bay are your first call for all your SharePoint queries throughout Australia. Help your company come together, even when they are apart by calling Devpro today.

Categories
Sharepoint

SharePoint Calculated Column WEEKDAY function

I was recently asked to setup a KPI indicator which calculates 3 days from a specified date excluding weekends. This is easily achieved using a calculated column in SharePoint, using the WEEKDAY function.
The WEEKDAY function receives a date and returns a number based on the day of the week the provided date falls on.
The syntax is WEEKDAY([DATE],x) where x specified the return type (1,2 or 3).

If no return type is specified it defaults to the first return type (1):
1: 1 Sunday
2 Monday
3 Tuesday
4 Wednesday
5 Thursday
6 Friday
7 Saturday

2: 1 Monday
2 Tuesday
3 Wednesday
4 Thursday
5 Friday
6 Saturday
7 Sunday

3: 0 Monday
1 Tuesday
2 Wednesday
3 Thursday
4 Friday
5 Saturday
6 Sunday

Logically I knew that if the date fell on Monday or Tuesday then we could add 3 days without needing to adjust for the weekends. Then if it fell on any other day than Sunday, we would need to add 2 days to the standard 3 days and in the case of a Sunday we would just need to add 1 additional day to the KPI calculations.


Since my logic is working forward from Monday, it seems appropriate to use either return type 2 or 3 and I will use return type 2 for this example.


We will also use an IF statement to control the logic with the following Syntax.

IF(TRUE, Then, else)

According to the WEEKDAY function, my logic would be:
If WEEKDAY returns less than or equal to 2 (Monday or Tuesday), then add 3 days to the specified date (No weekend to account for).

IF(WEEKDAY([Date],2)<=2,[Date] + 3,

Else if WEEKDAY returns less than equal 6 (Wednesday to Saturday), then add 5 days (3 days KPI plus 2 weekend days) to the specified date

IF(WEEKDAY([Date],2)<=6,[Date] + 5,

Else add 4 day to the specified date (3 Days KPI plus 1 weekend day being last remaining day Sunday)

[Date] + 4

Then we close our nested statements

))

The completed formula as entered SharePoint below:

=IF(WEEKDAY([Date],2)<=2,[Date]+3,IF(WEEKDAY([Date],6)<=2,[Date]+5,[Date]+4))

If you run into a similar challenge, I hope this might assist you to make sense of the WEEKDAY function and how you may put it to practical use.

Categories
Sharepoint

SHAREPOINT FILE MIGRATION

If you have files which are currently stored in local computer folders or network storage need to be migrated into SharePoint online. There are a few common issues which need to be observed in order to ensure trouble free migration.

INVALID CHARACTERS

~ ” # % & * : < > ? / \ { | }.

(Leading and trailing spaces in file or folder names also are not allowed.)

As described above is not suitable for saving in SharePoint due to the way web URLS are formed in the web browser. File systems may allow you to use them so they must be removed or fixed prior to migration.

LONG PATH NAME (WINDOWS)

In earlier versions of windows, and as default in current versions, the maximum length for a path is 260 characters. The path includes all the parent folders as well as the filename. We often find these issues when a series of folders with long names are used and nested within each other.  We do recommend shortening these paths if possible, prior to migration as a both good practice and to ensure adequate margin for SharePoint path limits.  Prior to migration you may also remove the windows limit via registry update in current windows versions to mitigate additional migration failure risk. See https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation

LONG PATH NAME (SHAREPOINT)

Like windows, SharePoint has a URL character limitation of 400 characters. All your files and folders will be nested under the URL path of the site and library which are also counted in the 400 characters. As such it pays to be diligent and accept the migration as an opportunity to restructure and enforce better practices for folder and file creation to prevent excessive nesting and long unnecessary names.

SHAREPOINT MIGRATION TOOL

Microsoft has created a migration tool to simplify the migration to SharePoint online. While we still recommend manually parsing your file and folder structure and preparing it for SharePoint online this tool will streamline the actual copy process and can remove invalid characters.

 You can download SharePoint Migration Tool here https://spmtreleasescus.blob.core.windows.net/install/default.htm

To automatically remove invalid characters, turn on ‘replace invalid characters’ in advanced settings.