1

Today I created a new site column named "Business Category" inside my issue tracking list on SharePoint 2013 server. The column type is a dropdown list. Now the internal name for the column is "Business_x0020_Category", as shown on the URL where the encoded name is "Business%5Fx0020%5FCategory" :- enter image description here

Now I try running this command to update the value of this column to all the items inside the list:-

$web = get-spweb "http://****/***/**/"
$list2 = $web.lists["Tracking"]
foreach ($i in $list2.items)
{
$a = $i["ID"];

$sourceItem = $list2.items.GetItemById($a);

$sourceItem["Business_x0020_Category"] = "User Delivery";

$sourceItem.Systemupdate();


}

but I got this error inside the PowerShell command:-

Column 'Business_x0020_Category' does not exist. It may have been deleted by
another user.
At line:5 char:1
+ $sourceItem["Business_x0020_Category"] = "User Delivery";
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException

so can anyone advise on this, please ?

and when I run the following command

$web = Get-SPWeb  $web = get-spweb "http://****/***/**/"
$list = $web.lists["Tracking"]
$list.fields | select InternalName, StaticName | sort StaticName | ft -AutoSize

the column Business_x0020_Category is listed in the list:

PS C:\Windows\system32> $list.fields | select InternalName, StaticName | sort StaticName | ft -AutoSize

InternalName                     StaticName
------------                     ----------
_CopySource                      _CopySource
_EditMenuTableEnd                _EditMenuTableEnd
_EditMenuTableStart              _EditMenuTableStart
_EditMenuTableStart2             _EditMenuTableStart2
_HasCopyDestinations             _HasCopyDestinations
_IsCurrentVersion                _IsCurrentVersion
_Level                           _Level
_ModerationComments              _ModerationComments
_ModerationStatus                _ModerationStatus
_UIVersion                       _UIVersion
_UIVersionString                 _UIVersionString
AppAuthor                        AppAuthor
AppEditor                        AppEditor
AssignedTo                       AssignedTo
AssignID                         AssignID
Attachments                      Attachments
Author                           Author
BaseName                         BaseName
Business_x0020_Category          Business_x0020_Category
Business_x0020_Development_x0020 Business_x0020_Development_x0020_Tracking_x...
businessfunctionsInitials        businessfunctionsInitials
Category                         Category
Comment                          Comment

so can anyone advise what is going on?

  • you might try to "View Source" to see what string represents that column when displayed in the browser? – Barry Prentiss Jul 7 '16 at 14:09
0

First, confirm that the field is actually among the list item's fields.

$sourceItem.Fields | select InternalName, StaticName | sort StaticName | ft -AutoSize

There's a possibility that the field, though attached to the list, has not been added to the content type of the list item.

Second, when using bracket notation to access an item's fields, you can always use the field's GUID instead of its display name or internal name.

The easiest way to obtain a field's GUID when you know its internal name is by calling GetFieldByInternalName on the list item's Fields collection.

To put this in practice, instead of:

$sourceItem["Business_x0020_Category"] = "User Delivery";

...use the following code:

$sourceItem[$sourceItem.Fields.GetFieldByInternalName("Business_x0020_Category").Id]
    = "User Delivery";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.