List Aggregator App (SPFx)

SharePoint Hosted Apps: Create Choice Type Column in SharePoint Online Office 365

SharePoint Hosted Apps Create Choice Type Column in SharePoint Online

This SharePoint hosted add-in or apps tutotial, we will discuss how to create a choice type site column and add mapping inside a SharePoint hosted add-in in SharePoint 2013 Online. We will do this inside a SharePoint hosted add-in using visual studio 2015/2017 in SharePoint Online.

In my previous I have explained how we can create a deploy a SharePoint Hosted Add-in (Apps) using Visual Studio, Check out the article here, before proceeding further.

SharePoint deveopment training course

SharePoint Hosted Apps: Create Choice Type Column in SharePoint Online

Once the SharePoint Hostes Add-in is ready follow below steps to add a site column of type choice.

Right click on Visual Studio 2015/2017 project -> Add -> New Item…

Then in the Add New Item dialog box, choose Site Column, give a name and then click on Add.

By default SharePoint will add Text type column like below:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Field
ID="{d8102081-02cf-48df-a41f-a4c9b914b313}"
Name="TrainingCourses"
DisplayName="Training Courses"
Type="Text"
Required="FALSE"
Group="Custom Site Columns">
</Field>
</Elements>

To add choice column, we can change the Type to Choice and then we can add the choices like below:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Field
ID="{d8102081-02cf-48df-a41f-a4c9b914b313}"
Name="TrainingCourses"
DisplayName="Training Courses"
Type="Choice"
Required="FALSE"
Group="Custom Site Columns">
<CHOICES>
<CHOICE>SharePoint 2016</CHOICE>
<CHOICE>SharePoint 2013</CHOICE>
<CHOICE>SharePoint 2010</CHOICE>
<CHOICE>SharePoint Online</CHOICE>
<CHOICE>Office 365</CHOICE>
<CHOICE>Microsoft Azure</CHOICE>
</CHOICES>
</Field>
</Elements>

To add mapping values, we can inside Mapping attribute like below. Similarly to add default value, we ca add inside attribute.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Field
ID="{d8102081-02cf-48df-a41f-a4c9b914b313}"
Name="TrainingCourses"
DisplayName="Training Courses"
Type="Choice"
Required="FALSE"
Group="Custom Site Columns">
<CHOICES>
<CHOICE>SharePoint 2016</CHOICE>
<CHOICE>SharePoint 2013</CHOICE>
<CHOICE>SharePoint 2010</CHOICE>
<CHOICE>SharePoint Online</CHOICE>
<CHOICE>Office 365</CHOICE>
<CHOICE>Microsoft Azure</CHOICE>
</CHOICES>

<MAPPINGS>
<MAPPING Value="1">SharePoint 2016</MAPPING>
<MAPPING Value="2">SharePoint 2013</MAPPING>
<MAPPING Value="3">SharePoint 2010</MAPPING>
<MAPPING Value="4">SharePoint Online</MAPPING>
<MAPPING Value="5">Office 365</MAPPING>
<MAPPING Value="6">Microsoft Azure</MAPPING>
</MAPPINGS>
<Default>SharePoint Online</Default>
</Field>
</Elements>

You may like following SharePoint Apps tutorials:

Hope this will be helpful to create a choice type site column in SharePoint Online by using SharePoint hosted add-in.

Check out Best Alternative to InfoPath -> Try Now

free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)

envelope
envelope

About Bhawana Rathore

Hello Everyone!! I am Bhawana a SharePoint MVP and having about 8+ years of SharePoint experience as well as in .Net technologies . I have worked in all the versions of SharePoint from wss to Office 365. I have good exposure in Customization and Migration using Nintex, Metalogix tools . Now exploring more in SharePoint 2016 :) Hope here I can contribute and share my knowledge to the fullest. As I believe "There is no wealth like knowledge, and no poverty like ignorance"

View all posts by Bhawana Rathore →