Skip to content

Set-ItemTemplate not copying all languages and all versions, if field ID is different #1259

@kningyi

Description

@kningyi

Expected Behavior

Set-ItemTemplate should perform the same as the c# method item.ChangeTemplate(templateItem).

Actual Behavior

When I use Set-ItemTemplate, only field values of the same field ID are preserved.

When I use Set-ItemTemplate with -FieldsToCopy argument, field values are always copied over, even if they are using standard values. Suggest adding a flag to omit copying if the field value is a standard value.

E.g. Template A has field named BannerImage (Item ID: 11111111...) and Template B has field named BannerImage (Item ID: 22222222...)

  • $item.ChangeTemplate($templateItemB) copies over such values by default, for all versions and languages.
  • $item | Set-ItemTemplate -TemplateItem $templateItemB does not copy such values by default.
    BannerImage value is left blank after changing the template.
  • $item | Set-ItemTemplate -TemplateItem $templateItemB -FieldsToCopy @{ "BannerImage" = "BannerImage"; } only copies such values only for the current $item.Version and $item.Language.
    Other versions and languages do not get the values.
  • $item | Set-ItemTemplate -TemplateItem $templateItemB -FieldsToCopy @{ "TextOne" = "TextTwo"; } copies TextOne value explicitly even when it's a standard value, causing the resulting TextTwo field to no longer be using the standard values from Template B.

Steps to Reproduce the Problem

  • Sitecore PowerShell Extensions 6.2.0.34182
  • Sitecore 10.0.1
  • Code:
    $item | Set-ItemTemplate -TemplateItem $templateItem -FieldsToCopy @{ "BannerImage" = "BannerImage"; "TextOne" = "TextTwo" }
    Take note BannerImage from source template has a different field ID as compared to BannerImage from target template

Metadata

Metadata

Assignees

Labels

area-commandsInvolves functions and cmdlets.impact-behaviour-changeNothing to be worried about. Now even better than before!🤩-release-highlightExciting change that should be highlighted in the release notes and celebrated by SPE fans.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions