Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Set-PnPPageTextPart and Set-PnPPageWebPart cmdlets are appending extra banner section along with existing banner in the updated page after updating the new text in the Text OOB component as well as in other Components #4313

Open
1 task
kssai94 opened this issue Sep 19, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@kssai94
Copy link

kssai94 commented Sep 19, 2024

Reporting an Issue

While setting new text value to the Text Out of the box webpart(using Set-PnPPageTextPart cmdlet) and also while updating the webpart properties back to other oob/custom webpart (using Set-PnPPageWebPart cmdlet) programmatically through powershell, Additional banner is getting appended along with the existing banner in the updated page.

Expected behavior

Set-PnPPageTextPart and Set-PnPPageWebPart cmdlets should set the new data only on the text out of the box webpart and custom/oob webpart respectively. It should not append any new banner in the updated page after setting the text/webpart properties.

Actual behavior

Set-PnPPageTextPart and Set-PnPPageWebPart cmdlets are appending new banner after setting the new text or webpart properties for text oob/custom webparts which is weird and strange.
Ideally It should not have duplicate banner in the updated page after setting new text content in webpart.
It should update only the new text content in the oob/custom webpart.

Steps to reproduce behavior

#Note: Please create a new Modern Page and add text OOB component and add some content in it and publish the page.
Then utilize the same page name below. Please use other parameters like credentials if you are unable to connect to Sharepoint Online.

Code Snippet

$siteUrl = ""
$appId = ""
$appSecret = ""

Connect to SharePoint Online
$global:pnpConnection = Connect-PnPOnline -Url "$($siteUrl)" -ClientId $appId -ClientSecret $appSecret -WarningAction Ignore ReturnConnection

$pageName = "<Any new page where a simple Text OOB webpart is added in a new section after the default banner section , Eg : Page-Text-Webpart.aspx>"

try {

#Main Function
$page = Get-PnPPage -Identity "$($pageName)" -Connection $global:pnpConnection

foreach ($control in $page.Controls) {

    try {
        
        #region Set Webpart Properties according to the language    
        
        $updatedText = "Iam fine"
        #$updatedText = "How are you?"
        #$updatedText = "Hope your family is well"
        # ConvertTo-Html -InputObject $control | Out-Null
        # Write-Host $($control.ControlType)
        if($control.Type.ToString().IndexOf("PageText") -ge 0){
            $control.ToHtml($control.ControlType) | Out-Null
            Set-PnPPageTextPart -Page $pageName -InstanceId $control.InstanceId -Text $updatedText -Connection $global:pnpConnection
        }
        elseif ($control.WebPartId -eq "<AnyGuid>"){
            $control.ToHtml($control.ControlType) | Out-Null
            Set-PnPPageWebPart -Page $pageName -Identity $control.InstanceId -PropertiesJson $control.JsonWebPartData -Connection $global:pnpConnection
        }

    }
    catch {
        Write-Host $_
        $pageConversionLogCount.Status = "Error"
    }
}

}
catch {
Write-Host "[ERROR]: $_ at $($.InvocationInfo.ScriptLineNumber) LineNumber In Main Function (Triggering Point)"
# log -content "[ERROR]: $
at $($_.InvocationInfo.ScriptLineNumber) LineNumber In Main Function (Triggering Point)" -path $logParentFilePath
$parentLogCount.Status = "Error"
}

$global:pnpConnection = $null

Page before updating new text in Text OOB webpart :
image

Page after updating new text in Text OOB webpart :
image

What is the version of the Cmdlet module you are running?

ModuleType Version Pre-release Name PSEdition

Manifest 2.1.1 PnP.PowerShell Desk

Which operating system/environment are you running PnP PowerShell on?

  • Windows

##Powershell Version - 7.4.5
##node version - v16.17.1
##npm version - 8.15.0

Please suggest a resolution for this issue.

Note : I'm able to reproduce the same issue by using latest PnP Version - 2.12.0, Kindly check and update.

Thank you,
Sreekrishna Sai

@kssai94 kssai94 added the bug Something isn't working label Sep 19, 2024
@jethva-aakash
Copy link

I am facing the same issue. For me, it happens when the Page has a Vertical Section. If I remove this Vertical section, it does not add the duplicate Page Title.

@kssai94
Copy link
Author

kssai94 commented Sep 23, 2024

Hi Aakash,

Thanks for the acknowledgement, But i'm still able to reproduce this issue after trying to update the webpart in new page or existing page.

Now : 23/09/2024 - 4.48PM IST

Thank you,
Sreekrishna Sai

@kssai94
Copy link
Author

kssai94 commented Sep 23, 2024

I am facing the same issue. For me, it happens when the Page has a Vertical Section. If I remove this Vertical section, it does not add the duplicate Page Title.

Hi Aakash, Could you please check once again as issue is again reproducing, Thanks

@kssai94 kssai94 changed the title [BUG] Set-PnPPageTextPart and Set-PnPPageWebParts cmdlets are appending extra banner section along with existing banner in the updated page after updating the new text in the Text OOB component as well as in other Components [BUG] Set-PnPPageTextPart and Set-PnPPageWebPart cmdlets are appending extra banner section along with existing banner in the updated page after updating the new text in the Text OOB component as well as in other Components Sep 23, 2024
@cibun
Copy link

cibun commented Sep 24, 2024

new version of the PowerShell
2.12.0 has fixed the issue.

@jethva-aakash
Copy link

We already tried V2.12.0 earlier but still the same. Following are some screenshots of the same,

01-NewPage

02-Update Text

03-Duplicate Header

@gautamdsheth
Copy link
Collaborator

Hello, can you please try again with latest nightly builds and let us know ? Looks like it has been fixed .

@jethva-aakash
Copy link

I tried with 2.12.19-nightly but still the same.

@tyagia10
Copy link

I tried even with 2.12.20-nightly but still facing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants