Derek Dysart

Derek Dysart


Periodic notes from an independent Sitecore Developer/Architect

April 2017
M T W T F S S
« Nov    
 12
3456789
10111213141516
17181920212223
24252627282930

Categories


Field Name Collisions in Sitecore Powershell Extensions

Derek DysartDerek Dysart

I had a situation where I needed to do a bulk update to a whole bunch of dictionary items that were part of a translation dictionary. On the dictionary entry template, there is a field called ‘Key’ which is also the name of a property on the Sitecore.Data.Items.Item class. I turns out that any field names that collide with properties on this object get an underscore in front of their name. For example, where I needed to get at the ‘Key’ field, I simply needed to write my Powershell command as:

Get-ChildItem -Recurse | Where-Object {$_.TemplateName -e “Dictionary Entry”} | ForEach-Object {$_._Key = $_.Name}

This particular PSE command will reset the Key field of all the Dictionary Entry items to its name.

Independent Sitecore developer. I also blog about other stuff from time to time.