0

Trying to update media item field through script .In the csv file I have item name for uploaded images that needs to be updated in the Imagefield

script:

 $AllPhotoGallery = Get-ChildItem -Path "master://sitecore/media library/Images/photo-gallery" -Recurse
 $Mediaimage = $AllPhotoGallery   | Where-Object { $_."DisplayName" -eq $PropertyPhotoName  };

        $ID = $Property."Photos"

        $Property.Editing.BeginEdit();
        $Property["Photos"] = $ID;  #Here

Field: enter image description here

0

My understanding from your sample code is that you want to edit a field which contains 0 or or more item IDs. The documentation site has some examples for this.

Example: The following adds new Ids to an existing list. Makes use of the Sitecore.Text.ListString class.

[Sitecore.Text.ListString]$ids = $item.Fields["Photos"].Value
$ids.AddAt(0,"{guid1}") > $null
$ids.Add("{guid2}") > $null
$ids.Add("{guid3}") > $null

$item.Editing.BeginEdit()
$item.Fields["Photos"].Value = $ids.ToString()
$item.Editing.EndEdit() > $null
  • I want to update image from csv to the field – sindu Jan 11 at 18:03
  • Please update your question to more succinctly explain the requirements. At the moment it does not clearly indicate that you need to update from a csv, what the csv structure is currently, etc. – Michael West Jan 11 at 18:30

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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