How to Create a New SharePoint List and Adding a Choice Field in it By Using PNP
Softree Technology > Blogs > SharePoint > How to Create a New SharePoint List and Adding a Choice Field in it By Using PNP

How to Create a New SharePoint List and Adding a Choice Field in it By Using PNP

  • Posted by: Softree Technology

Now a days there is high demand in PNP as there is less execution of codes and all is done by executing a number of commands in PNP.

  • Procedure:
  • Connect to the site:

At first connect to the site where you want to create a new list and choice field of it.

To connect to the SharePoint list you must run the following PNP command as given below.

$credentials = Get-Credential
$siteurl = “https://softreetechss.sharepoint.com”
Connect-PnPOnline -Url $siteurl -Credentials $credentials

In the Place of siteurl give the url of your site.

After executing the command you will be prompted for the credentials of the site as shown below.

After providing the credentials of your site, you can create a new list in your site.

  • Create a newlist:

To create a new list in your site you should run the following command as given below.

Add-PnPField -List “Demo4 Test” -DisplayName “Demo4”    

After running the script you will notice that the newlist have been created in your site as shown below.

  • Add Choice field in newly created list:

To create the new choice field in the newly created list you should run the following command as given below.

Add-PnPField -List “Demo4Test” -DisplayName “Language” -Type Choice  -AddToDefaultView -Choices “English”,”French”,”Dutch”

After running the script you will notice that the new field is created in your list as shown below.

After creating the field it is time to use those choices which we added through the command and those choices are 1. English, 2. French, 3. Dutch.

To use these choices you need to add an item in the newly created list and you can see these choices as shown below.

Now you can select any of these choices as per your requirement and then click on save.

After that you will see that the new item with its selected field is ready as shown below.

Conclusion:
Hello to all dear readers, in this blog I have explained to create a new list and adding a choice field in it by using PNP. Hope you will enjoy it.

Keywords:
* SharePoint Online
* SharePoint List
* Choice Field
* PNP

Author: Softree Technology

Leave a Reply