I have created a site column of type "People or Group" and i name it "Software Development Risk/Issue Owner". now i added this site column inside multiple lists. now i find this confusing issue.
when i access the site column from the site level i inspected the following Internal name Software_x0020_Development_x0020_Risk_x002F_Issue_x0020_Owner
from the URL :-
/_layouts/15/ManageContentTypeField.aspx?ctype=0x0103004AFB52A22B74934CB139F46F5A802B7505&Field=Software%5Fx0020%5FDevelopment%5Fx0020%5FRisk%5Fx002F%5FIssue%5Fx0020%5FOwner&Fid=
while when i access the site column from one of the list levels, i inspected the following Internal name Software_x0020_Development_x0020
from the URL :-
/_layouts/15/FldEditEx.aspx?CloseOnCancel=1&List={60F9B143-EBA4-47C6-B714-3AA863B26AAC}&Field=Software%5Fx0020%5FDevelopment%5Fx0020&Source=
so my First question is why the site column have 2 different internal names ; one at the site level while the other at the list level ?
Second question, now i wanted to move some items from one list named "Action" to another list named "Risk Issue" , using the following power-shell script :-
$web = get-spweb "http://*****/teamsites/SoftwareDevelopment/"
$list = $web.lists["Action"]
$list2 = $web.lists["Risk Issue"]
foreach ($i in $list.items)
{
$a = $i["ID"];
$sourceItem = $list.items.GetItemById($a)
$versions = $sourceItem.versions;
$newItem = $list2.items.Add();
$versionCount = $versions.Count;
##We need a for loop here as we must work backwards through the version collection
for ($i = $versionCount;$i -gt 0;$i--)
{
$version = $versions[$i-1];
$newItem["Title"] = $version["Title"];
##code goes here.....
$newItem["Software_x0020_Development_x0020_Risk_x002F_Issue_x0020_Owner"] = $version["Software_x0020_Development_Manager"];
$newItem.Update();
}
}
but i got this exception :-
Column 'Software_x0020_Development_x0020_Risk_x002F_Issue_x0020_Owner' does not exist. It may have been deleted by another user. At line:21 char:5 + $newItem["Software_x0020_Development_x0020_Risk_x002F_Issue_x0020_Owner"] = ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ + CategoryInfo : OperationStopped: (:) [], ArgumentException + FullyQualifiedErrorId : System.ArgumentException
now if i replace this $newItem["Software_x0020_Development_x0020_Risk_x002F_Issue_x0020_Owner"]
with this $newItem["Software_x0020_Development_x0020"]
(in other words i used the list level internal name instead of the site level internal name ) the exception will disappear .. so what is causing this? i always reference the site columns as defined inside the site level,, not sure why in this case i can not do so ?
can anyone adivce on this please ?
-----------EDIT-------
For my second question i did the following test . Here my test for 3 columns:-
1) First Column have its internal name at the list level = "DueDate
", while at the site level its internal name = "TaskDueDate
".
2) Second Column have its internal name at the list level = "Technical_x0020_Delivery_x0020_T
", while at the site level its internal name = "Technical_x0020_Delivery_x0020_Team
".
3) Third Column have its internal name at the list level = Software_x0020_Development_x0020
, while at the site level its internal name =
Software_x0020_Development_x0020_Risk_x002F_Issue_x0020_Owner
.
now on the first and third site columns i was NOT able to reference the columns using their site level internal names as shown below, as i will get an error inside the powershell windows that it can not find these columns
$newItem["TaskDueDate"
]
&
$newItem["Software_x0020_Development_x0020_Risk_x002F_Issue_x0020_Owner"]
and i have to use their internal names as defined inside the list level (not site level), so this will not raise an error:-
$newItem["DueDate"
]
&
$newItem["Software_x0020_Development_x0020"]
while for the second column i was able to reference it either using its site level or list level internal names.. so can anyone adivce what is the rule that govern this ?