Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Powershell to create column with different internal name and display name

$
0
0
Hello all,

How do I create a column with different internal name and display name in powershell?

I use the following xml

<?xml version="1.0" encoding="utf-8"?><Fields><Field Type="Choice" DisplayName="Question One" Required="TRUE" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="RadioButtons" FillInChoice="FALSE"  StaticName="Question" Name="Question" ColName="nvarchar3" RowOrdinal="0" Version="1"><CHOICES><CHOICE>1</CHOICE><CHOICE>2</CHOICE><CHOICE>3</CHOICE><CHOICE>4</CHOICE><CHOICE>5</CHOICE></CHOICES></Field></Fields>



Powershell I use 

......
.......
$templateXmlLocation = ($currentFolderPath + "\" + $xmlFile); //Path to the xml file
 $templateXml = [xml](get-content $templateXmlLocation)
 foreach ($node in $templateXml.Fields.Field)
 {
   $spList.Fields.AddFieldAsXml($node.OuterXml, $true,[Microsoft.SharePoint.SPAddFieldOptions]::AddFieldToDefaultView)
 }
 $spList.Update()
When the column is created, its internal name comes as "Question_x0020_One instead of just Question. Kindly help.


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>