August 8, 2024

Resolving Power Automate Flow Trigger Issues when Migrating Items to a SharePoint List

Introduction:

Automation in SharePoint using Power Automate can significantly streamline processes and enhance productivity. However, certain scenarios, such as bulk item migrations, can lead to unintended behaviors. This blog post will share a recent problem encountered with an automated flow triggered by item creation in a SharePoint list. We will also walk you through the steps we took to resolve this issue effectively.

Problem:

We had set up an automated flow in Power Automate that trigger whenever a new item is created in a SharePoint list. Before migrating many items, we turned off this flow to prevent it from triggering for each migrated item. After completing the migration and reactivating the flow, we observed an unexpected behavior, the flow triggered for all the newly migrated items due to data stored in the browser cache. This resulted in uneven and unwanted executions of the flow.

Steps to the solution:

To avoid this issue in future migrations, we followed an approach that ensures the flow does not trigger unintentionally during bulk item migrations. Here are the steps:


Step 1: Export the Flow

Before starting the migration process, export the existing flow to your local machine. This step ensures that you have a backup of the flow configuration and can easily restore it later.

  1. Open Power Automate.
  2. Navigate to the flow which you want to export.
  3. Select the flow and open it.
  4. Select "Export", then click on the "Package (.zip)"
  5. In the opened "Package details" section, Give the Name of the package.
  6. Click on the exported .zip file and download it to your computer.

     



Step 2: Delete the Existing Flow

With the flow exported and safely stored, proceed to delete the existing flow. This step prevents any triggers from occurring during the migration process.
  1. Navigate to the flow which you want to delete.
  2. Click on “Delete” and it will ask for confirmation. 


Step 3: Migrate the Items

Now that the flow has been deleted, proceed with migrating the items to the SharePoint list. Since the flow is not present, it will not trigger during this process.


Step 4: Recreate the Flow by Importing the Zip File

After completing the migration, recreate the flow by importing the previously exported .zip file. This ensures that the flow is restored to its original configuration.
  1. Navigate to the location where you want to Import.
  2. Click on "Import" -> Import Package (Legacy).
  3. Upload the .zip file that you exported earlier; it will take some time to complete the process.
  4. In Review Package Content – click on the "Update" link from IMPORT SETUP.
  5. It will open an "Import setup" panel, in the Setup field we need to select the "Create as new" option and then click on the Save button.
  6. Click on the Import button. [Note: It will take some time to Import the file, so please do not navigate away]
  7. Once the Import is completed then you will get a successfully imported message.


Step 5: Verify and Reactivate the Flow Once the flow is successfully imported, verify its configuration to ensure everything is set up correctly. Then, reactivate the flow.
  1. Locate the newly imported flow.
  2. Ensure the configuration is correct and click on "Turn on" to reactivate it. 

Conclusion:

By following these steps, you can effectively manage your automated flows in Power Automate and avoid unintended triggers during bulk item migrations. Exporting and deleting the flow before migration, and then recreating it afterward, ensures that your automation behaves as expected and maintains data integrity. This method provides a reliable solution to prevent the issues caused by browser cache and uneven flow triggering.

Implementing this approach will save you time and effort, ensuring a smooth migration process without disrupting your automated workflows.






If you have any questions you can reach out our SharePoint Consulting team here.

July 31, 2024

Migrating Permissions across SharePoint sites using ShareGate

In SharePoint, permissions are crucial for ensuring appropriate access to resources within SharePoint sites. There may be instances where you need to replicate the permissions of one site to another. To achieve this, a method for copying or migrating SharePoint site permissions from one site to another is necessary.


In this article, we will provide a step-by-step guide on how to copy or migrate SharePoint site permissions from one site to another.


For Migrating the Permission we will be using the ShareGate Migration Tool, Its a migration tool that simplifies and accelerates migration processes directly to the latest SharePoint or Microsoft 365.

Prerequisites:

  • ShareGate licence

  • ShareGate Migration Tool Installed

  • The user performing this action must be a Site Collection Administrator

  • PowerShell version 3.0 or higher (Note: This will not work with version 7.0)


Migrating permissions across sites involves not only assigning users to their respective groups but also migrating the Permission Roles, SharePoint Groups, and their associated Users.

We will be migrating the Permissions using two methods.

Method 1 Using ShareGate Migration tool:

The ShareGate migration tool offers user-friendly features that simplify any migration task. When migrating permissions, you can select the source site and destination site, ensure proper mapping, and migrate the permissions with just a click. Follow the steps below to migrate permissions using the migration tool.


Step 1: Open the ShareGate Migration Tool. In the left section, click on "Copy" and then select "Copy Structure and Content."



Step 2: Enter the source site URL, select "Browser for Authentication," and log in with your credentials.


Step 3: Similarly, log in to the destination site by entering the destination URL and selecting "Browser" as the authentication type. Once logged in to both the source and destination sites, you will see the following interface.



Step 4: First, migrate the Permission Levels, and then migrate the SharePoint Groups from the source site to the destination site.


Select the Permission Levels, choose the specific Permission Levels you want to migrate, and then click "Start Copy."



With this, the permission roles will be copied to the destination site. Next, we can proceed to migrate the SharePoint Groups across the sites.


Open the SharePoint Groups from the Site Objects.


Step 5: Now, select all the groups that you want to migrate to the destination site.


Make sure that Mapping is set for the default Groups of SharePoint like Members, Owners and Visitors under mappings as shown below.


ShareGate Mapping provides a way to map the source object with destination and set the content accordingly in the destination as per the mapping.



Now, click "Start Copy" to begin copying the SharePoint groups along with their members.


After the copying task is completed, you will see that the groups have been migrated. You can also verify the members of each group by checking the respective site.

Method 2: Using ShareGate & PnP PowerShell

PowerShell is a robust command-line tool that can automate numerous tasks in Microsoft 365. For copying SharePoint site permissions from one site to another, we will use ShareGate PowerShell. Execute the following PowerShell script to copy the SharePoint site permissions.


Note: Please ensure that you have the Sharegate module imported before running this script. Additionally, ensure that PnP.PowerShell version 1.12 is installed (ShareGate Migration tool must be installed on your system).


To import the Sharegate module, use the following command:


Import-Module Sharegate

To install PnP.PowerShell version 1.12, use:

Install-Module PnP.PowerShell -RequiredVersion 1.12 -Force

  • Execute the script provided below.

  • Enter your login credentials when prompted to access the site.

  • The script will then continue its execution.


#Config Parameters
$SourceSite = "<<Source Site>>"
$DestinationSite = "<<Destination Site>>"


#Function to Copy-Migrate the SharePoint Site Level Permission from one site to another
Function Copy-MigrateSiteLevelPermission {
    param (
        $DestinationSite,
        $SourceSite
    )
   
    Write-Host "Establishing the connection between source site and destination site..."
    $Source = Connect-Site -Url $SourceSite -Browser
    $Destination = Connect-Site -Url $DestinationSite -UseCredentialsFrom $Source
   
    Write-Host "Setting up the Mappings for the Default SharePoint Groups..."
    $mappingSettings = New-MappingSettings
    $mappingSettings = Set-UserAndGroupMapping -Source "Destination Site Members" -Destination "Source Members"
    $mappingSettings = Set-UserAndGroupMapping -MappingSettings $mappingSettings -Source "Destination Site  Owners" -Destination "Source Owners"
$mappingSettings = Set-UserAndGroupMapping -MappingSettings $mappingSettings -Source "Destination Site Visitors" -Destination "Source Visitors"
Write-Host "Copying the Permission from one site to another..." Copy-ObjectPermissions -Source $Source -Destination $Destination -MappingSettings $mappingSettings Write-Host "Permission Copied Successfully from one site to another..." -f Green } #Function to Copy the Permission Level from one site to another Function Copy-PermissionLevel { param ( $DestinationSite, $SourceSite ) Write-Host "Connecting with Source and Destination Site..." $SourceSiteConnection = Connect-PnPOnline -Url $SourceSite -UseWebLogin -ReturnConnection $DestinationSiteConnection = Connect-PnPOnline -Url $DestinationSite -UseWebLogin -ReturnConnection Write-Message "Starting the Migration Process for Permission Levels..." Write-Message "Reading all the Permission Level From source site..." $AllPermissionLevel = Get-PnPRoleDefinition -Connection $SourceSiteConnection foreach ($permissionLevel in $AllPermissionLevel) { $permissionLevelName = $permissionLevel.Name Write-Host "Migration: $permissionLevelName" Write-Host "Checking permission level $permissionLevelName..." if (!(Get-PnPRoleDefinition -Identity $permissionLevelName -ErrorAction SilentlyContinue -Connection $DestinationSiteConnection)) { Write-Host "Creating new permission level $permissionLevelName..." if ($permissionLevel.PermissionLevels) { Add-PnPRoleDefinition -RoleName $permissionLevelName -PermissionLevels $permissionLevel.PermissionLevels -Description $permissionLevel.Description -Connection $DestinationSiteConnection } else { Add-PnPRoleDefinition -RoleName $permissionLevelName -Clone $permissionLevel -Description $permissionLevel.Description -Connection $DestinationSiteConnection } } } Write-SuccessMessage "Permission Level Migration Completed successfully..." } #Execute the Function to Copy the Permission Level Copy-PermissionLevel -DestinationSite $DestinationSite -SourceSite $SourceSite #Execute the Function with Parameter to Copy the Groups and other Permissions Copy-MigrateSiteLevelPermission -DestinationSite $DestinationSite -SourceSite $SourceSite

Upon successful execution of the script, you will observe that permission roles within SharePoint Groups have been copied from one site to another. This demonstrates how ShareGate PowerShell and the ShareGate Migration tool facilitate the migration of SharePoint site permissions between sites.

If you have any questions you can reach out our SharePoint Consulting team here.