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

Fix Add-PnPDataRowsToSiteTemplate setting KeyColumn to null #4325

Merged

Conversation

jackpoz
Copy link
Contributor

@jackpoz jackpoz commented Sep 21, 2024

Type

  • Bug Fix
  • New Feature
  • Sample

Related Issues?

Fixes pnp/pnpframework#1020

What is in this Pull Request ?

This PR fixes Add-PnPDataRowsToSiteTemplate setting KeyColumn to null when the -KeyColumn parameter is not passed. It also fixes the case of -KeyColumn parameter value being ignored.
The old code was updating listInstance.DataRows.KeyColumn only when the -KeyColumn parameter was null, but it should update it only when it's not null.

How to reproduce steps:

  1. Get a list template
Get-PnPSiteTemplate -ListsToExtract "Test simple list" -Handlers Lists -Out "list.xml"
  1. Manually add a DataRows section to the ListInstance with KeyColumn value set
<pnp:DataRows UpdateBehavior="Overwrite" KeyColumn="Title">
</pnp:DataRows>
  1. Call Add-PnPDataRowsToSiteTemplate without -KeyColumn parameter
Add-PnPDataRowsToSiteTemplate -List "Test simple list" -Path "list.xml"
  1. Check the KeyColumn attribute in the template

@gautamdsheth gautamdsheth merged commit 8df1f04 into pnp:dev Sep 21, 2024
2 checks passed
@gautamdsheth
Copy link
Collaborator

Awesome stuff as always @jackpoz , thank you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Add-PnPDataRowsToSiteTemplate clears PnP: DataRows properties
2 participants