0

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 and creating new columns within existing lists.

My elements.xmlschema.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?

1 Answer 1

0

I've had sporadic success using the XML based provisioning to create/update assets from SPFx component installs & upgrades.

FWIW, Microsoft has said for many years the best way to provision isn't to use the Feature framework (ie: XML), rather use the API (ie: REST). That's what I recommend & do now...

After installing the component, the first time it's used it does a check to see "is everything as I expect it". In your scenario, that would be "is the column present that I expect."

If not, the web part shows a friendly "error" with guidance to open the tool pane. That explains the situation, tells someone with valid permissions to use click a button in the toolpane that makes the change via REST).

Yes, it's a bit more work, but (1) it's debuggable whereas when XML provisioning doesn't work, it's just a black box with zero logs/errors) and (2) its reliable.

Your Answer

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

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