6

i have created list and columns in SPFx app using elemets.xml and schema.xml. Now after doing this i want to add new column to already created list. I have created elements-v2.xml and upgrade-actions-v2.xml with the following codes i.e,

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

<Field ID="{A9E2A4DC-720D-426E-B674-E13722DF9208}"
        Name="SPFxTagsAmount1"
        DisplayName="SPFxTagsAmountDisplay1"
        Type="Currency"
        Decimals="2"
        Min="0"
        Required="FALSE"
        Group="SPFx Columns" />   

</Elements>

and

<AddContentTypeField 
 ContentTypeId="0x010042D0C1C200A14B6887742B6344675C8B" 
 FieldId="{A9E2A4DC-720D-426E-B674-E13722DF9208}" 
 PushDown="TRUE" />
<ApplyElementManifests>
  <ElementManifest Location="523fe887-ced5-4036-b564-8dad5c6c6e24\elements-v2.xml" />
</ApplyElementManifests>

and referenced the new column in schema.xml i.e,

    <Views>
  <View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/generic.png" Url="AllItems.aspx">
    <XslLink Default="TRUE">main.xsl</XslLink>
    <JSLink>clienttemplates.js</JSLink>
    <RowLimit Paged="TRUE">30</RowLimit>
    <Toolbar Type="Standard" />
    <ViewFields>
      <FieldRef Name="ID" />
      <FieldRef Name="SPFxTagsAmount" />
      <FieldRef Name="LinkTitle"></FieldRef>
      <FieldRef Name="SPFxAmount"></FieldRef>
      <FieldRef Name="SPFxCostCenter"></FieldRef>
    </ViewFields>
    <Query>
      <OrderBy>
        <FieldRef Name="ID" />
      </OrderBy>
    </Query>
  </View>
</Views>

and in the package-solution.json added the following line in the features property.

"upgradeActions": [
        "upgrade-actions-v2.xml"
      ]

After incrementing version for both solution and feature, i redeployed it. List has not updated. Any help ?, where am i doing wrong ?? Followed Provisioning SharePoint assets from your SharePoint client-side web part.

5
  • Have you tried switching the AddContentTypeField and ApplyElementManifests in upgrade-actions-v2.xml so that the field is created before you try to add it to the content type? Apr 25, 2017 at 18:47
  • AddContentTypeField and ApplyElementManifests are already in upgrade-actions-v2.xml, the issue is with AddContentTypeField, whenever i use it inupgrade-actions-v2.xml , package is not upgraded and so is version. Apr 26, 2017 at 5:25
  • 1
    I can see they are in there, but you have the AddContentTypeField before the ApplyElementManifests and logically it should be after Apr 26, 2017 at 7:03
  • Yup you are right, logical error. Corrected and got the result. Thanks Apr 26, 2017 at 7:33
  • Has anybody been able to bind a field to an existing content type (native), at the first deployment of the app (without the upgradeActions) ?
    – JayHell
    May 8, 2018 at 19:49

1 Answer 1

2

Swap the order of elements in upgrade-actions-v2.xml, so it becomes:

<ApplyElementManifests>
  <ElementManifest Location="523fe887-ced5-4036-b564-8dad5c6c6e24\elements-v2.xml" />
</ApplyElementManifests>
<AddContentTypeField 
 ContentTypeId="0x010042D0C1C200A14B6887742B6344675C8B" 
 FieldId="{A9E2A4DC-720D-426E-B674-E13722DF9208}" 
 PushDown="TRUE" />

That'll create the field before you add it to the content type.

2
  • Hi Per, if you have any idea about how to update list schema in SPFx ?? Apr 27, 2017 at 6:07
  • 1
    No being limited to AddContentTypeField and ApplyElementManifests seems to make this impossible for the moment Apr 27, 2017 at 7:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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