0

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?

1
  • 3
    In 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.
    – Ghanendra
    Sep 12, 2023 at 12:06

2 Answers 2

3

This is how you can try to get the value of two fields of the same name. This is my item.

enter image description here

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.

enter image description here

Hope this helps.

3

I have created two same field names Title as per your requirement.

enter image description here

And updated different content on different field

enter image description here

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:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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