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

Set-ItemTemplate should support fields copying to aid with templates that do not have matching fields #847

Closed
AdamNaj opened this Issue Mar 1, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@AdamNaj
Member

AdamNaj commented Mar 1, 2017

This is a scenario that I've seen being a problem multiple times, e.g. here or here.

We have 2 templates:

  • User Defined/Source - with fields: Field1, Field2, Field3
  • User Defined/Target - with fields: Field4, Field5, Field6

and Item at path master:\content\home\TemplateChangeTest that is of template User Defined/Source.
I want to change the item template to User Defined/Target and make the following transformation:

  • Field1 -> Field4
  • Field2 -> Field5
  • Field3 -> Field6

All other fields have counterparts with a matching name in the User Defined/Target template.

The following script should do the trick:

Set-ItemTemplate -Path master:\content\home\TemplateChangeTest `
    -Template "User Defined/Target" `
    -FieldsToCopy @{Field1="Field4"; Field2="Field5"; Field3="Field6"}

@AdamNaj AdamNaj added this to the 4.4.2 milestone Mar 1, 2017

@AdamNaj AdamNaj self-assigned this Mar 1, 2017

AdamNaj added a commit that referenced this issue Mar 1, 2017

AdamNaj added a commit that referenced this issue Mar 1, 2017

@AdamNaj

This comment has been minimized.

Member

AdamNaj commented Mar 1, 2017

Implemented

@AdamNaj AdamNaj closed this Mar 1, 2017

@michaellwest

This comment has been minimized.

Member

michaellwest commented Mar 1, 2017

You're a hero to many @AdamNaj !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment