Power Automate - Overview of SharePoint Field XML Schema

Power Automate: Overview of SharePoint Field XML Schema

No comments

Loading

In this article, we will understand SharePoint Field XML Schema, what exactly it is, and how to use it in Power Automate to create a new field. Then we will learn how to create various other columns using the Field Schema XML and Power Automate in SharePoint Online. Before that, we will understand what field schema XML is in SharePoint.

What is SharePoint Field Schema XML?

SharePoint Field Schema XML, often referred to as FieldXML or Field Schema, is a critical component of Microsoft SharePoint, a widely used platform for document management, collaboration, and content management. Field Schema XML is an XML-based markup language used to define and configure custom fields within SharePoint lists and libraries. It provides a structured way to specify the characteristics, behavior, and appearance of custom fields, allowing organizations to tailor SharePoint to their specific needs.

Here’s a detailed explanation of SharePoint Field Schema XML:

  • Custom Fields: SharePoint supports a wide range of built-in field types (e.g., text, number, date), but organizations often have unique data requirements that necessitate the creation of custom fields. These custom fields can capture and display specialized information that is not covered by the default field types.
  • Field Definition: To create custom fields, SharePoint administrators and developers use Field Schema XML to define the field’s properties and behavior. This XML document serves as a blueprint for how the field should be presented and processed within SharePoint.
  • XML Structure: Field Schema XML follows a specific structure and syntax defined by Microsoft. It typically consists of various XML elements and attributes that specify different aspects of the custom field. Here are some common elements and attributes:
<Field>: The root element that encapsulates all the field properties.
Type: Specifies the data type of the field (e.g., Text, Number, DateTime).
DisplayName: Sets the name that appears to users when interacting with the field.
Description: Provides a description of the field's purpose.
Required: Determines whether the field is mandatory or optional.
DefaultValue: Defines a default value for the field.
Choices: For choice-based fields (e.g., Dropdown, Radio Buttons), this element specifies the available options.
Formula: Allows the creation of calculated fields based on other fields' values.
  • Validation and Formatting: Field Schema XML allows you to define validation rules and formatting options for custom fields. For example, you can specify that a text field should only accept email addresses or enforce a date format.
  • Display Settings: You can control how the field is displayed to users by configuring settings such as width, alignment, and whether it appears in list views and forms.
  • Event Handlers: SharePoint Field Schema XML also enables the attachment of event handlers, which are custom scripts or code that execute when specific field-related events occur (e.g., when a value is changed).
  • Deployment: Once the Field Schema XML is defined, it can be deployed to SharePoint sites and associated with lists or libraries. This allows users to create and manage items with the custom field.
  • Versioning and Updates: Field Schema XML can be versioned and updated as needed. Changes to the schema may require data migration or updates to existing items using the custom field.

SharePoint Field Schema XML is a structured markup language used to define and configure custom fields within SharePoint lists and libraries. It provides a way to tailor SharePoint’s data structures to specific organizational needs, allowing for the creation of custom fields with various properties, behaviors, and display settings. This customization is essential for organizations looking to adapt SharePoint to their unique business processes and requirements.

SharePoint Field Schema XML Examples

Following are the various field schema xml in SharePoint Online:

Single Line of Text Column:

<Field
ID="New Guid for the column, see at the bottom how to get it"
Name="Your Column Internal Name"
DisplayName="Your Column Display Name"
StaticName="Your Column Static Name"
Description="Your Column Description"
Type="Text"
Required="TRUE"
EnforceUniqueValues="FALSE"
Indexed="FALSE"
MaxLength="255"
Group="Your Column Group"
SourceID="http://schemas.microsoft.com/sharepoint/v3"/>

Multiple Lines of Text Column

<Field
ID="New Guid for the column, see at the bottom how to get it"
Name="Your Column Name"
DisplayName="Your Column Display Name"
Description="Your Column Description"
StaticName="Your Column Static Name"
Group="Your Column Group"
Type="Note"
NumLines="5"
UnlimitedLengthInDocumentLibrary="TRUE"
Hidden="FALSE"
ShowInEditForm="TRUE"
SourceID="http://schemas.microsoft.com/sharepoint/v3"/>

Choice Column

<Field
ID="New Guid for the column, see at the bottom how to get it"
Name="Your Column Internal Name"
DisplayName="Your Column Display Name"
StaticName="Your Column Static Name"
Description="Your Column Description" 
Group="Your Column Group"
Type="Choice"
Required="TRUE"
EnforceUniqueValues="FALSE"
Indexed="FALSE"
Format="Dropdown"
FillInChoice="FALSE"> 
<Default>Option #1</Default>
<CHOICES>
<CHOICE>Option #1</CHOICE>
<CHOICE>Option #2</CHOICE>
<CHOICE>Option #3</CHOICE>
<CHOICE>Option #4</CHOICE>
<CHOICE>Option #5</CHOICE>
</CHOICES>
</Field>

Number Column

<Field
  ID="New Guid for the column, see at the bottom how to get it"
  Name="Your Column Internal Name"
  DisplayName="Your Column Display Name"
  StaticName="Your Column Static Name"
  Description="Your Column Description" 
  Group="Your Column Group"
  Type="Number"
  Hidden="false"
  ShowInNewForm="FALSE"
  ShowInEditForm="FALSE"
  Min="0"
  Max="2"
  Decimals="0">
  <Default>0</Default>
</Field>

 

Currency Column

<Field
ID="New Guid for the column, see at the bottom how to get it"
Name="Your Column Internal Name"
DisplayName="Your Column Display Name"
StaticName="Your Column Static Name"
Description="Your Column Description" 
Group="Your Column Group"
Type="Currency"
Required="FALSE"
EnforceUniqueValues="FALSE"
Indexed="FALSE"
Decimals="2"
LCID="1033"
SourceID="http://schemas.microsoft.com/sharepoint/v3"/>
CustomFormatter=""
/>

DateTime Column

<Field
ID="New Guid for the column, see at the bottom how to get it"
Name="Your Column Internal Name"
DisplayName="Your Column Display Name"
StaticName="Your Column Static Name"
Description="Your Column Description" 
Group="Your Column Group"
Type="DateTime" 
Required="FALSE"
EnforceUniqueValues="FALSE"
Indexed="FALSE"
Format="DateTime" 
FriendlyDisplayFormat="Disabled" 
ShowInEditForm="FALSE"
SourceID="http://schemas.microsoft.com/sharepoint/v3"/>
ShowInNewForm="FALSE">
</Field>


Yes/No Column

<Field
ID="New Guid for the column, see at the bottom how to get it"
Name="Your Column Internal Name"
DisplayName="Your Column Display Name"
StaticName="Your Column Static Name"
Description="Your Column Description" 
Group="Your Column Group" 
Type="Boolean" 
Required="FALSE"
EnforceUniqueValues="FALSE"
Indexed="FALSE"
Hidden="TRUE" 
ShowInEditForm="FALSE"
ShowInNewForm="FALSE"
ShowInViewForms="FALSE"
ShowInDisplayForm="FALSE">
<Default>FALSE</Default>
</Field>

Calculated Column

<Field
ID="New Guid for the column, see at the bottom how to get it"
Name="Your Column Internal Name"
DisplayName="Your Column Display Name"
StaticName="Your Column Static Name"
Description="Your Column Description" 
Group="Your Column Group" 
Type="Calculated"
ResultType="Number" 
Hidden="false"
JSLink="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js|~site/Scripts/Fields.JSLink.js">
<FieldRefs>
<FieldRef Name="StatusColumn1" />
<FieldRef Name="StatusColumn2" />
<FieldRef Name="StatusColumn3" />
<FieldRef Name="StatusColumn4" />
<FieldRef Name="StatusColumn5" />
</FieldRefs>
<Formula>=[StatusColumn1]+[StatusColumn2]+[StatusColumn3]+[StatusColumn4]+[StatusColumn5]</Formula>
</Field>



Lookup Column

<Field
ID="New Guid for the column, see at the bottom how to get it"
Name="Your Column Internal Name"
DisplayName="Your Column Display Name"
StaticName="Your Column Static Name"
Description="Your Column Description" 
Group="Your Column Group" 
Type="Lookup"
Required="FALSE"
EnforceUniqueValues="FALSE"
List="Source List Title"
ShowField="Source List Column (example: Title)"
/>

Person Column

<Field
ID="New Guid for the column, see at the bottom how to get it"
Name="Your Column Internal Name"
DisplayName="Your Column Display Name"
StaticName="Your Column Static Name"
Description="Your Column Description" 
Group="Your Column Group" 
Type="User" 
List="UserInfo"
Required="FALSE"
EnforceUniqueValues="FALSE"
ShowField="ImnName"
UserSelectionMode="PeopleOnly"
UserSelectionScope="0"
ShowInEditForm="FALSE"
ShowInNewForm="FALSE"> 
</Field>


Note:
  • In the above, ShowField=”ImnName” is the username.

Hyperlink Column

<Field
ID="New Guid for the column, see at the bottom how to get it"
Name="Your Column Internal Name"
DisplayName="Your Column Display Name"
StaticName="Your Column Static Name"
Description="Your Column Description" 
Group="Your Column Group"
Type="URL" 
Required="TRUE"
EnforceUniqueValues="FALSE"
Indexed="FALSE"
ShowInEditForm="FALSE"
ShowInNewForm="FALSE"
Format="Hyperlink">
</Field>

 

What is the recommended way to generate the above column’s XML (Field XML Schema)?

If you copy and paste the column XML, you may face some syntactical errors. So, how do you generate column XML yourself without referring to any articles and without any errors? The first thing you need to do is, as a pre-requisite, create a test list if you don’t have one, then manually create all the above-mentioned columns, and retain this test list permanently as a template to use whenever you need it.

Use the below REST API in your Send an HTTP Request to SharePoint GET action:

_api/web/lists/getbyTitle('Your List Title')/fields/getByTitle('Your Column Title')/SchemaXML

For more details, refer to this article: How to get column XML from SharePoint List

Execute this REST API query from your Power Automate one by one for all your columns, whichever you need. While you get your column XML using Power Automate, you will have the GUID of your existing column, so you must pass a new GUID for your new column. Learn here how to generate a new GUID for a new column in the Power Automate flow.

Using Power Automate and SharePoint Field Schema XML Create Column

Once you have generated XML for your new column, you can create a new column using the new column XML. For more details, refer to this article, where it is explained step by step – How to create column in SharePoint List Using CreateFieldAsXML.

Summary: Overview of SharePoint Field XML Schema

Thus, in this article, we have learned what SharePoint Field Schema XML is,  how to generate field XML schema from SharePoint, and finally, how to create a new column by passing the field XML schema in the Power Automate Send an HTTP Request to SharePoint action.

See Also: Helpful Power Automate Articles

You may also like the following Power Automate articles:

 

About Post Author

Do you have a better solution or question on this topic? Please leave a comment