Articles about European Sharepoint Hosting Service
SharePoint 2013 Hosting – HostForLIFE :: Create Lookup Field In Existing SharePoint List Using REST API Schema XML
In this article, we will learn how to create a lookup field in an existing SharePoint list using REST API and schema XML. The REST API enables us to communicate with SharePoint using standard HTTP methods, such as GET, POST, PUT, and DELETE. The API provides access to various SharePoint entities including lists, libraries, and sites, allowing us to retrieve data, create and update lists, fields, items, upload files and manage user permissions.
Prerequisites
- Access to a SharePoint site with permissions to create lists and fields
Below are the steps,
Step 1. Create a lookup list
The first step is to create the list that you want to be the source of the lookup field. I will use the “Department” list with the “Title” column as a source for creating the lookup field in this demo.
Step 2. Create a new list
Create a new list and use it to create a multiselect lookup field by using the lookup list created in the previous step as its source.
Step 3. Create REST API request body
For creating the multiselect lookup field using the REST API, we need to define the request body for the API call. This body will contain the schema XML for the field, which must include the following properties:
- FieldType: Specifies the type of the field. For multiselect lookup fields, the value should be “LookupMulti”.
- Name: The internal name of the field.
- DisplayName: The name of the field as it will be displayed in the list.
- Required: Specifies whether the field is required or not.
- List: The ID of the lookup list.
- Mult: Specifies that the field is a multiselect field.
- ShowField: The name of the source field from the lookup list.
Step 4. Make the REST API Call
With the request body defined, you are now ready to make the REST API call. You can use any REST client to make the call, such as Postman. The REST API call should be made to the following URL:
The request should be a POST request and the request body should contain the schema XML defined in the previous step.
Output
After making the REST API call, you can verify that the multiselect lookup field was created by going to the destination list’s settings page and checking the list of fields.
List view
Print article | This entry was posted by Peter on February 10, 2023 at 3:15 am, and is filed under European SharePoint 2013 Hosting. Follow any responses to this post through RSS 2.0. Both comments and pings are currently closed. |