2

I have a list with content type in it. I'm trying to add a field to this content type so I can use it in the library. Here's I've added Elements.1.0.0.1.xml file to Content Type:

    <?xml version="1.0" encoding="utf-8" ?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
     <Field ID="{63F353F8-F206-4BB0-A3C1-1B8FA9E43C63}" DisplayName="Dull field" Name="DULLfield" Type="Text" Group="RM" Overwrite="TRUE" />
    </Elements>

Then I've added Upgrade Action to Feature.Template.xml:

    <UpgradeActions>
    <VersionRange BeginVersion="0.0.0.0" EndVersion="10.0.0.0">
      <ApplyElementManifests>
        <ElementManifest Location="MyContentType\Elements.1.0.0.1.xml"/>
      </ApplyElementManifests>
      <AddContentTypeField ContentTypeId="0x0120D520005C2CAF72F4414435A29E0ACDC59F28D9" FieldId="{63F353F8-F206-4BB0-A3C1-1B8FA9E43C63}" PushDown="TRUE"/>
    </VersionRange>
  </UpgradeActions>

Then I run following script with no errors or warnings:

    Update-SPSolution -Identity sharepointproject1.wsp -LiteralPath  "C:\SharePointProject1.wsp" -GA
CDeployment

Now I can see new field in Site Columns, but not in my Content Type. I suppose PushDown="TRUE" parameter has to add new field to a content type, but it doesn't. What do I miss?

======== Update ======== Deployed solution with Version = 1.0.0.0, then changed Version to 2.0.0.0, Publish WSP file to local disk, run Update-SPSolution. When I get Solution version via PowerShell

$f = Get-SPFeature | where{$_.DisplayName -eq '
myfeature'}
$f.version 

It's still 1.0.0.0. I've opened wsp feature.xml file inside wsp file - it has correct version 2.0.0.0

What do I miss?

0

Give versioning to the feature, i.e. VersionRange id, then remove from VersionRange the BeginVersion property.

Exemple:

<Feature xmlns="http://schemas.microsoft.com/sharepoint/" Version="10.0.0.0">
  <UpgradeActions>
    <VersionRange EndVersion ="10.0.0.0">
      <ApplyElementManifests>
        <ElementManifest Location="MyContentType\Elements.1.0.0.1.xml"/>
      </ApplyElementManifests>
      <AddContentTypeField ContentTypeId="0x0120D520005C2CAF72F4414435A29E0ACDC59F28D9" FieldId="{63F353F8-F206-4BB0-A3C1-1B8FA9E43C63}" PushDown="TRUE"/>
    </VersionRange>
  </UpgradeActions>
</Feature>

Hope it helps.

  • didn't help ... – Chetvergov Aug 29 '14 at 11:53
  • Where are your Elements definition? – Nicoleta Andreea Soare Aug 29 '14 at 11:56
  • Both old and new files are in the Content Type thread in solution explorer (Elements.xml and Elements.1.0.0.1.xml). I've just now run powershell cmdlet to get the feature version and it's "0.0.0.0". Now I'm trying to figure out another way to set feature version... – Chetvergov Aug 29 '14 at 12:38
  • It might seem stupid but is your SharePointProjectItem.spdata under the thread updated? Can you see the file in the feature? If yes then there might be a problem with the powershell script. – Nicoleta Andreea Soare Aug 29 '14 at 12:46
  • It's unupdated indeed! I've tried again just now: Recreate Site Collection, then deploy feature with Version=1.0.0.0, then changed Version to Version=2.0.0.0 in Feature.Template.xml, but after upgared feature still has Version=2.0.0.0 (checked bu powershell). I think there's another way to set feature version... – Chetvergov Aug 29 '14 at 13:17
0

I've finally got the upgrade done. Here's a list of actions I proceeded:

1.Update spsolution (.wsp file):

   Update-SPSolution -Identity SharePointProject58.wsp -LiteralPath "<Path>" -GACDeployment

2.Upgrade feature:

    $feature = $web.Features | where{$_.Definition.DisplayName -eq '*myfeature*'} 
$feature.Upgrade($true)

And the most important part: You have to restart console after every time you update solution, otherwise it sticks to old version! Here's good article on the subject.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.