I want to write a script to bulk update the link field title
and text
for all the components of a particular type to Read more
but I struggle with figuring out how to update these properties.
Here is a part of my script which takes all the search results items and goes through them to update the link field text and title but after this code is invoked and I try to read the $item.Fields["Link"].Text or Value
there is no new value written so I assume that they are not saved correctly.
Could you please point me out what is wrong here?
...
$item.Editing.BeginEdit()
[Sitecore.Data.Fields.LinkField]$linkField = $item.Fields["Link"]
if($item.Version.Count -gt 0) {
Switch ($item.Language){
"en" {
# I tried different things like below
$linkField["Text"] = "Read more"
$linkField.Text = "Read more"
}
"de" {
...
}
...
}
#Trying to assign the new values to the link field but when I try to read it afterwards does not work
$item.Fields["Link"].Value = $linkField.Value
}
$item.Editing.EndEdit() > $null