Updating a list in SharePoint framework - SPFx WebPart

%3CLINGO-SUB%20id%3D%22lingo-sub-2655545%22%20slang%3D%22en-US%22%3EUpdating%20a%20list%20in%20SharePoint%20framework%20-%20SPFx%20WebPart%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2655545%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20followed%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2Fspfx%2Fweb-parts%2Fget-started%2Fprovision-sp-assets-from-package%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ethis%20tutorial%3C%2FA%3E%26nbsp%3Band%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2Fspfx%2Ftoolchain%2Fprovision-sharepoint-assets%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ethis%20documentation%3C%2FA%3E%26nbsp%3Bin%20order%20to%20create%20lists%20and%20columns%20within%20SharePoint%20Online.%20Everything%20seems%20to%20work%20fine%20when%20creating%20them%20for%20the%20first%20time.%20But%20when%20I%20try%20to%20modify%20an%20existing%20column%20or%20add%20a%20new%20column%20within%20an%20existing%20list%20using%26nbsp%3B%3CEM%3Eelements-v2.xml%3C%2FEM%3E%2C%20after%20redeploying%20the%20app%20in%20my%20app%20catalogue%20then%20updating%20the%20existing%20app%2C%20the%20new%20and%20modified%20columns%20haven't%20been%20created.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20only%20thing%20that%20works%20successfully%20after%20updating%20my%26nbsp%3B%3CEM%3Eelements-v2.xml%26nbsp%3B%3C%2FEM%3Eis%20creating%20new%20lists.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%26nbsp%3B%3CEM%3Eelements.xml%2C%3C%2FEM%3E%26nbsp%3B%3CEM%3Eschema.xml%26nbsp%3B%3C%2FEM%3Eand%20%3CEM%3Epackage-solution.json%26nbsp%3B%3C%2FEM%3Eare%20the%20same%20as%20in%20the%20tutorial%20in%20the%20first%20link.%3C%2FP%3E%3CP%3EWithin%26nbsp%3B%3CEM%3Eelements-v2.xml%3C%2FEM%3E%20I%20have%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%0A%3CELEMENTS%20xmlns%3D%22http%3A%2F%2Fschemas.microsoft.com%2Fsharepoint%2F%22%3E%0A%20%20%3CLISTINSTANCE%20featureid%3D%2200bfea71-de22-43b2-a848-c05709900100%22%20title%3D%22New%20List%22%20description%3D%22New%20list%20provisioned%20from%20v2%22%20templatetype%3D%22100%22%20url%3D%22Lists%2FNewList%22%3E%0A%20%20%3C%2FLISTINSTANCE%3E%0A%0A%3CFIELD%20id%3D%22%7B943E7530-5E2B-4C02-8259-CCD93A9ECB18%7D%22%20name%3D%22SPFxCostCenter%22%20displayname%3D%22Cost%20Center%22%20type%3D%22Choice%22%20required%3D%22FALSE%22%20group%3D%22SPFx%20Columns%22%3E%0A%20%20%20%20%20%20%20%20%3CCHOICES%3E%0A%20%20%20%20%20%20%20%20%3CCHOICE%3EAdministration%3C%2FCHOICE%3E%0A%20%20%20%20%20%20%20%20%3CCHOICE%3EInformation%3C%2FCHOICE%3E%0A%20%20%20%20%20%20%20%20%3CCHOICE%3EFacilities%3C%2FCHOICE%3E%0A%20%20%20%20%20%20%20%20%3CCHOICE%3EOperations%3C%2FCHOICE%3E%0A%20%20%20%20%20%20%20%20%3CCHOICE%3ESales%3C%2FCHOICE%3E%0A%20%20%20%20%20%20%20%20%3CCHOICE%3EMarketing%3C%2FCHOICE%3E%0A%20%20%20%20%20%20%20%20%3CCHOICE%3ENew%20Choice%3C%2FCHOICE%3E%0A%20%20%20%20%20%20%20%20%3C%2FCHOICES%3E%0A%20%20%20%20%3C%2FFIELD%3E%0A%0A%3C%2FELEMENTS%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWithin%20my%26nbsp%3B%3CEM%3Eupgrade-actions-v2.xml%26nbsp%3B%3C%2FEM%3E%20I%20have%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3CAPPLYELEMENTMANIFESTS%3E%0A%20%20%3CELEMENTMANIFEST%20location%3D%224d9c0146-1219-986c-8d4e-984b42efd732%5Celements-v2.xml%22%3E%3C%2FELEMENTMANIFEST%3E%0A%3C%2FAPPLYELEMENTMANIFESTS%3E%0A%0A%3CADDCONTENTTYPEFIELD%20contenttypeid%3D%220x010042D0C1C200A14B6887742B6344675C8B%22%20fieldid%3D%22%7B943E7530-5E2B-4C02-8259-CCD93A9ECB20%7D%22%20pushdown%3D%22TRUE%22%3E%3C%2FADDCONTENTTYPEFIELD%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EA%20few%20years%20ago%2C%20one%20of%20my%20colleagues%20worked%20on%20a%20project%20adding%20and%20updating%20existing%20columns%20this%20way%2C%20but%20neither%20of%20us%20can%20work%20out%20why%20it%20won't%20work%20this%20time.%3CBR%20%2F%3E%3CBR%20%2F%3EDoes%20anyone%20have%20any%20suggestions%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2655545%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESharePoint%20Framework%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2797008%22%20slang%3D%22en-US%22%3ERe%3A%20Updating%20a%20list%20in%20SharePoint%20framework%20-%20SPFx%20WebPart%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2797008%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1130244%22%20target%3D%22_blank%22%3E%40Easty12345%3C%2FA%3E%26nbsp%3Bdid%20you%20manage%20to%20resolve%20this%3F%20I'm%20facing%20a%20similar%20issue...%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2797671%22%20slang%3D%22en-US%22%3ERe%3A%20Updating%20a%20list%20in%20SharePoint%20framework%20-%20SPFx%20WebPart%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2797671%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1130244%22%20target%3D%22_blank%22%3E%40Easty12345%3C%2FA%3E%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F410110%22%20target%3D%22_blank%22%3E%40dhendry%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20would%20need%20to%20add%20the%20attribute%20Overwrite%20%3D%20%22TRUE%22%20(if%20you%20don't%20have%20any%20subsites)%20but%20if%20you%20have%20subsites%2C%20you%20would%20also%20need%20to%20add%20the%20attribute%20OverwriteInChildScopes%26nbsp%3B%3D%20%22TRUE%22.%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22FeliciaA_0-1632972614832.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F313882i4E6B3F14D1D501CD%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22FeliciaA_0-1632972614832.png%22%20alt%3D%22FeliciaA_0-1632972614832.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EIt%20is%20by%20design%20for%20a%20choice%20field%20that%20by%20default%20the%20existing%20field%20will%20not%20be%20updated.%26nbsp%3B%20This%20is%20because%20often%20end%20users%20or%20site%20owners%2Fadmin%20may%20make%20some%20changes%20to%20the%20choice%20values%2Foptions%20so%20you%20would%20need%20to%20be%20careful%20and%20make%20sure%20that%20noone%20is%20making%20any%20changes%20to%20the%20existing%20field%20that%20you%20don't%20want%20to%20overwrite%20when%20deploying%20the%20choice%20field.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20this%20helps.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheers%3C%2FP%3E%3CP%3EFelicia%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

I have followed this tutorial and this documentation in order to create lists and columns within SharePoint Online. Everything seems to work fine when creating them for the first time. But when I try to modify an existing column within an existing list using elements-v2.xml, after redeploying the app in my app catalogue then updating the existing app, the modified columns haven't been updated.

 

The only thing that works successfully after updating my elements-v2.xml is creating new lists or adding columns to existing lists.

 

My elements.xml, schema.xml and package-solution.json are the same as in the tutorial in the first link.

Within elements-v2.xml I have:

(I want to add an additional choice on line 24)

 

 

 

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <ListInstance
    FeatureId="00bfea71-de22-43b2-a848-c05709900100"
    Title="New List"
    Description="New list provisioned from v2"
    TemplateType="100"
    Url="Lists/NewList">
  </ListInstance>

<Field ID="{943E7530-5E2B-4C02-8259-CCD93A9ECB18}"
            Name="SPFxCostCenter"
            DisplayName="Cost Center"
            Type="Choice"
            Required="FALSE"
            Group="SPFx Columns">
        <CHOICES>
        <CHOICE>Administration</CHOICE>
        <CHOICE>Information</CHOICE>
        <CHOICE>Facilities</CHOICE>
        <CHOICE>Operations</CHOICE>
        <CHOICE>Sales</CHOICE>
        <CHOICE>Marketing</CHOICE>
        <CHOICE>New Choice</CHOICE>
        </CHOICES>
    </Field>

</Elements>

 

 

 

 

Within my upgrade-actions-v2.xml  I have:

 

 

 

 

<ApplyElementManifests>
  <ElementManifest Location="4d9c0146-1219-986c-8d4e-984b42efd732\elements-v2.xml" />
</ApplyElementManifests>

<AddContentTypeField 
     ContentTypeId="0x010042D0C1C200A14B6887742B6344675C8B" 
     FieldId="{943E7530-5E2B-4C02-8259-CCD93A9ECB18}" 
     PushDown="TRUE" />

 


Does anyone have any suggestions on how I can modify an existing column using spfx?

2 Replies

@Easty12345 did you manage to resolve this? I'm facing a similar issue... 

Hi, @Easty12345@dhendry 

 

You would need to add the attribute Overwrite = "TRUE" (if you don't have any subsites) but if you have subsites, you would also need to add the attribute OverwriteInChildScopes = "TRUE". 

FeliciaA_0-1632972614832.png

It is by design for a choice field that by default the existing field will not be updated.  This is because often end users or site owners/admin may make some changes to the choice values/options so you would need to be careful and make sure that noone is making any changes to the existing field that you don't want to overwrite when deploying the choice field.

 

Hope this helps.

 

Cheers

Felicia