From aaabb1162431f1b421c142fe1ce82f63171681a8 Mon Sep 17 00:00:00 2001 From: "Bobby Abellana (aider)" Date: Wed, 19 Feb 2025 15:41:23 -0800 Subject: [PATCH] fix: Handle Shared Documents URL format and update config --- SharePointFunctions.ps1 | 15 +++++++++++---- config.json | 4 ++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/SharePointFunctions.ps1 b/SharePointFunctions.ps1 index 3ac1e61..27be4eb 100644 --- a/SharePointFunctions.ps1 +++ b/SharePointFunctions.ps1 @@ -111,7 +111,7 @@ function Move-Files { function Get-FolderBrowser { try { # Get site ID first - $siteUrl = $script:txtSiteUrl.Text + $siteUrl = $script:txtSiteUrl.Text.TrimEnd('/') $site = Get-MgSite -Search $siteUrl | Where-Object { $_.WebUrl -eq $siteUrl } if (-not $site) { @@ -120,10 +120,17 @@ function Get-FolderBrowser { # Get drive (document library) $drives = Get-MgSiteDrive -SiteId $site.Id - $drive = $drives | Where-Object { $_.Name -eq $script:txtProdLib.Text } + # Handle "Shared Documents" special case + $libraryName = if ($script:txtProdLib.Text -eq "Shared Documents") { + "Documents" + } else { + $script:txtProdLib.Text + } + $drive = $drives | Where-Object { $_.Name -eq $libraryName } if (-not $drive) { - throw "Library not found" + $script:txtStatus.Text += "Available libraries: $($drives.Name -join ', ')`n" + throw "Library not found: $libraryName" } # Get folders @@ -134,7 +141,7 @@ function Get-FolderBrowser { $folderObjects = $folders | ForEach-Object { [PSCustomObject]@{ Name = $_.Name - ServerRelativeUrl = "/sites/$($site.Name)/$($drive.Name)/$($_.Name)" + ServerRelativeUrl = "/sites/tax/Shared Documents/$($_.Name)" } } diff --git a/config.json b/config.json index 8ff7682..9b2ca26 100644 --- a/config.json +++ b/config.json @@ -1,5 +1,5 @@ { "SiteUrl": "https://sutterhill.sharepoint.com/sites/tax/", - "ProductionLibrary": "", - "TempLibrary": "" + "ProductionLibrary": "Shared Documents", + "TempLibrary": "Temp" }