sometimes i can not understand how i need to write a robust power script inside sharepoint 2013, specifically when it comes to site columns Display Name versus internal names.
now i have the following site column, where its internal name is
ItemNumber while its Display name is
Item Number as shown here:-
now i wanted to assign this field a JSlink, so i tried the following script by referencing the site column using its internal name:-
$web = Get-SPWeb http://servername/ $field = $web.Fields["ItemNumber"] $field.PushChangesToLists = $true $field.JSLink = "~siteCollection/Resources/hideItemNumberinQucikEdit.js" $field.update() $web.Update() $web.Dispose()
but i got this error on the 3rd line:-
PS C:\Users***> $field.PushChangesToLists = $true Property 'PushChangesToLists' cannot be found on this object; make sure it exists and is settable. At line:1 char:1 + $field.PushChangesToLists = $true + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) , RuntimeException + FullyQualifiedErrorId : PropertyNotFound
now i modified my original script so inastead of using "ItemNumber" which represents the internal name, i used the "Item Number" which represents the display name, as follow:-
$web = Get-SPWeb http://servername/ $field = $web.Fields["Item Number"] $field.PushChangesToLists = $true $field.JSLink = "~siteCollection/Resources/hideItemNumberinQucikEdit.js" $field.update() $web.Update() $web.Dispose()
and my script worked well. but still i am 100% confused. As i know that sharepoint understand internal names for the columns,, or it will look for internal and then display names,,, but what i can not understand is that when i use the column internal name the script did not work, but when i used the column display name the script worked!!
also as mentioned on this link https://msdn.microsoft.com/library/microsoft.sharepoint.splistitem
For an indexer based on a name, Microsoft SharePoint Foundation first looks for the field by internal name and then by display name.
so can anyone advice what is going on ?