There are two fields with the same name Title
in a Sitecore item, Is there a way to get the values of both fields using Sitecore PowerShell?
-
3In Sitecore PowerShell, you can also get fields by their GUID - $_.Fields[<Field GUID here>]. As such, there will be no conflict even if multiple fields have same name. But it is not a good practice for 2 or more fields to have same name in a template. It can affect content authoring experience unless there is a way to differentiate between them.– GhanCommented Sep 12, 2023 at 12:06
2 Answers
This is how you can try to get the value of two fields of the same name. This is my item.
And this is the script
$item = Get-Item master:\content\home\new
Get-Item -Path "master:" -Query "/sitecore/content/home/new" |
Show-ListView -property "Title", @{Label="Title2"; Expression={$_.Fields["{76D4FC9B-ADC1-496E-AB3A-0264679D65A2}"].Value}}
In the above query for Title2 label, I have given the field ID of the same field name.
And it will give me results like this.
Hope this helps.
I have created two same field names Title
as per your requirement.
And updated different content on different field
Below is the reference of PowerShell script to get both Title
fieldx
Get-Item -Path master:/content/home | Format-Table -Property "Title", @{Label="Title"; Expression={$_.Fields["BC04DED0-3D1C-4891-84CD-6FA42C8ADBB3"]} }
And result is: