pnp / pnp/pnpframework

[BUG] User field not taken on ContactFieldControl webpart

Open
#356 3 comments 0 reactions 1 assignee View on GitHub

@jansenbe is already working on this.

Since May 28, 2021.

area: page transformation 🦾 question
Dominant language
C#
Stars
259
Forks
161
Avg merge
10h 33m
Merged PRs (30d)
1

Description

Thank you for reporting a bug. We appreciate your feedback - to help the team to understand your needs, please complete the below template to ensure we have the necessary details to assist you. Thanks!

Problem Area

[x] Page Transformation: Error during the use of page transformation from PnP PowerShell
[ ] Page Transformation: Error during the use of page transformation from .Net
[ ] Page Transformation: Page is not looking correct after transformation
[ ] Modernization Scanner: something went wrong...

Expected or Desired Behavior

Using the Powershell command
ConvertTo-PnPPage -Identity $page.FieldValues["ID"]
-PublishingPage
-TargetWebUrl $targetSiteUrl
-PublishingTargetPageName $targetFileName
-Connection $sourceConnection
-KeepPageCreationModificationInformation
-PageLayoutMapping "C:\Temp\custompagelayoutmapping-xxx.xml"
-WebPartMappingFile "C:\Temp\webpartmapping-xxx.xml"
-PostAsNews
-Overwrite
-SkipItemLevelPermissionCopyToClientSidePage
-LogSkipFlush
-SkipUserMapping
-LogType File
-CopyPageMetadata
-LogFolder "c:\temp"
-ClearCache

with custompagelayoutmapping-xxx.xml (relevant section)
<Field Name="xxxContact" TargetWebPart="Microsoft.SharePoint.Portal.WebControls.ContactFieldControl, Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" Row="1" Column="2"> <Property Name="Title" Type="string" Functions="StaticString({xxxContactDescription})" /> <Property Name="Description" Type="string" /> <Property Name="Frametype" Type="string" /> <Property Name="PartImageLarge" Type="string" /> <Property Name="ID" Type="string" /> <Property Name="ContactLoginName" Type="string" /> </Field>

and webpartmapping-xxx.xml (relevant section)
<!-- Contact web part --> <WebPart Type="Microsoft.SharePoint.Portal.WebControls.ContactFieldControl, Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" CrossSiteTransformationSupported="true"> <Properties> <Property Name="IsIncluded" Type="bool"/> <Property Name="Dir" Type="string"/> <Property Name="PartImageSmall" Type="string"/> <Property Name="PartImageLarge" Type="string"/> <Property Name="IsIncludedFilter" Type="bool"/> <Property Name="CacheTimeout" Type="integer" /> <Property Name="ContactLoginName" Type="string" Functions="LookupPerson({ContactLoginName})"/> </Properties> <Mappings Selector="UserExistsSelector({PersonEmail})"> <Mapping Name="ValidUser" Default="true"> <ClientSideWebPart Type="People" Order="10" JsonControlData="&#123;&quot;serverProcessedContent&quot;&#58;&#123;&quot;htmlStrings&quot;&#58;&#123;&#125;,&quot;searchablePlainTexts&quot;&#58;&#123;&quot;title&quot;&#58;&quot;{Title}&quot;,&quot;persons[0].name&quot;&#58;&quot;{PersonName}&quot;,&quot;persons[0].email&quot;&#58;&quot;{PersonEmail}&quot;&#125;,&quot;imageSources&quot;&#58;&#123;&#125;,&quot;links&quot;&#58;&#123;&#125;&#125;,&quot;dataVersion&quot;&#58;&quot;1.2&quot;,&quot;properties&quot;&#58;&#123;&quot;layout&quot;&#58;1,&quot;persons&quot;&#58;[&#123;&quot;id&quot;&#58;&quot;{PersonEmail}&quot;,&quot;upn&quot;&#58;&quot;{PersonUPN}&quot;,&quot;role&quot;&#58;&quot;{PersonRole}&quot;,&quot;department&quot;&#58;&quot;{PersonDepartment}&quot;,&quot;phone&quot;&#58;&quot;{PersonPhone}&quot;,&quot;sip&quot;&#58;&quot;{PersonSip}&quot;&#125;]&#125;&#125;"/> </Mapping> <Mapping Name="InvalidUser" Default="false"> <ClientSideText Order="10" Text="User with ID {ContactLoginName} could not be found. Mapping to People web part was skipped."/> </Mapping> </Mappings> </WebPart>

Desired behaviour would be
i) accepting a user field as input for the ContactFieldControl, e.g. <Field Name="xxxContact" TargetWebPart="Microsoft.SharePoint.Portal.WebControls.ContactFieldControl ...

ii) resolving the user from the user field input and fill the desired modern "people" web part accordingly

Observed Behavior

i) using any user field as input yields "Microsoft.SharePoint.Portal.WebControls.ContactFieldControl, Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c is not added for field [Fieldname] because the field value was empty and the RemoveEmptySectionsAndColumns flag was set".

  • xxxContact is not empty (the mapping <Field Name="xxxContact" TargetFieldName="xxxKontakt" Functions="" /> is working)
  • same for any other user e.g. Editor
  • as a workaround, I used <Field Name="Title" TargetWebPart="Microsoft.SharePoint.Portal.WebControls.ContactFieldControl ... just to avoid the incorrect "field value was empty" error that is thrown on any user field. Then, any of these lines
    <Property Name="ContactLoginName" Type="string" Functions="{xxxContact}" />
    <Property Name="ContactLoginName" Type="string" Functions="StaticString({xxxContact})" />
    <Property Name="ContactLoginName" Type="string" Functions="ToAuthors({xxxContact})" />
    do not work.
    The next line is the only way I got the People webpart produced and filled with an user:
    <Property Name="ContactLoginName" Type="string" Functions="StaticString('i:0#.f|membership|xx.xx@xx.de')" />
  • btw, the flag -RemoveEmptySectionsAndColumns for Powershell ConvertTo-PnPPage does not make sense here, because it is already the default behaviour. There should be a flag like -KeepEmptySectionsAndColumns
  • and a very last question: is there a way to use a multi value people field to fill the People webpart (Powershell)?

PnP PowerShell version:
ModuleType Version Name
Manifest 1.5.0 PnP.PowerShell

Output from PowerShell session:
PS C:\Users\xxx> C:\Users\xxx\OneDrive - xxx\Code\Sharepoint\convert-to-modern2.ps1
Connecting to https://xxx.sharepoint.com/sites/intranet/aktuelles/archiv
Gathering news articles... 8 items found.
[1/8] Processing xxx-Mai-2021.aspx... OK
Report saved as: c:\temp\Page-Transformation-Report-27.05.2021-14-36-54.md
Done.

Report:

Modernization Summary Report

Date Duration Source Page Target Page Url Status
27.05.2021 14:36:54 00:00:20 /aktuelles/archiv/Seiten/xxx-Mai-2021.aspx /SitePages/xxx-Mai-2021.aspx Successful with 1 warnings and 0 non-critical errors

Warnings during transformation

Date Source Page Operation Message
27.05.2021 14:36:57 /aktuelles/archiv/Seiten/xxx-Mai-2021.aspx Publishing Page analyzer Target web part Microsoft.SharePoint.Portal.WebControls.ContactFieldControl, Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c is not added for field Editor because the field value was empty and the RemoveEmptySectionsAndColumns flag was set
27.05.2021 14:37:14 /aktuelles/archiv/Seiten/xxx-Mai-2021.aspx Article page handling
Steps to Reproduce

See above

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.