none
SharePoint 2019 Only- SharePoint SPField SchemaXml not updating RRS feed

  • Question

  • I have a SharePoint 2019 environment in which I have one SharePoint field.

    I want to update the SchemaXML for the list dynamically and add one custom attribute in it.

    The logic to add attribute in schema and updating it is working of SP2013 and SP2016 but it is not getting the effect in SP 2019.

    Let me know if you need more details for this.

    Thanks in advance!!!

    Tuesday, August 13, 2019 11:45 AM

All replies

  • Hi Sigar,

    Is it possible for you to share the SchemaXML to see the issue in detailed.

    Regards,

    Krishna 

    Tuesday, August 13, 2019 1:46 PM
  • Here you go,

    THis is an OOTB Name field which has the internal name as "FileLeafRef"

    <Field ID="{8553196d-ec8d-4564-9861-3dbe931050c8}" ShowInFileDlg="FALSE" ShowInVersionHistory="FALSE" Type="File" Name="FileLeafRef" DisplayName="Name" AuthoringInfo="(for use in forms)" List="Docs" FieldRef="ID" ShowField="LeafName" JoinColName="DoclibRowId" JoinRowOrdinal="0" JoinType="INNER" Required="TRUE" NoCustomize="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="FileLeafRef" FromBaseType="TRUE"  />

    I want to add my own custom attribute to this which will store a string. I have my logic related to that.

    An attribute which I want to add is be like:

    StoreImagesList="Site Collection Documents"

    Which will make the schemaxml as :

    <Field ID="{8553196d-ec8d-4564-9861-3dbe931050c8}" ShowInFileDlg="FALSE" ShowInVersionHistory="FALSE" Type="File" Name="FileLeafRef" DisplayName="Name" AuthoringInfo="(for use in forms)"
     List="Docs" FieldRef="ID" ShowField="LeafName" JoinColName="DoclibRowId" JoinRowOrdinal="0" JoinType="INNER" Required="TRUE" NoCustomize="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3"
     StaticName="FileLeafRef" FromBaseType="TRUE" StoreImagesList="Site Collection Documents" />

    I have a code which reads the XMLSchema and add an attribute in it. 

    But when I am assigning this new schema with my custom attribute it is not reflecting.

    I have already tried SPField.Update(); SPField.Update(true) and also List and Web Updates.

    The line:

    field.SchemaXML = newXMLSchema (This is new updated schema)

    But this is not working

    Thanks

    Sigar Dave



    Thanks Sigar Dave


    • Edited by Sigar V Dave Tuesday, August 13, 2019 2:05 PM Changes
    Tuesday, August 13, 2019 2:03 PM
  • Hi, Dave,

    I tested in my end and find meet the same issue with you. It seems we cannot directly change the SchemaXML for build-in hidden fields now (works for custom fields). I will recommend you to open a ticket and ask for more information about the change in SP 2019.

    Best Regards

    Jerry


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Wednesday, August 14, 2019 9:46 AM