Skip to main content
added 5 characters in body; added 75 characters in body
Source Link
vandsh
  • 1.7k
  • 11
  • 17

As far as editing an item, your script looks to be doing what it needs to, but I'm guessing the actual date value is not something Sitecore recognized for a Date type field. Depending on the date format your CSV contains, you will likely need to utilize the Sitecore.DateUtil class to parse it into something that field can accept:

$currentItem.Editing.BeginEdit()
$csvDate = [DateTime]::ParseParseExact($row."publish date","dd/MM/yyyy HH:mm:ss",[Globalization.cultureinfo]::GetCultureInfo("en-US"))
$currentItem["Publish Date"] = [Sitecore.DateUtil]::ToIsoDate($csvDate)
$currentItem.Editing.EndEdit();

As far as editing an item, your script looks to be doing what it needs to, but I'm guessing the actual date value is not something Sitecore recognized for a Date type field. Depending on the date format your CSV contains, you will likely need to utilize the Sitecore.DateUtil class to parse it into something that field can accept:

$currentItem.Editing.BeginEdit()
$csvDate = [DateTime]::Parse($row."publish date")
$currentItem["Publish Date"] = [Sitecore.DateUtil]::ToIsoDate($csvDate)
$currentItem.Editing.EndEdit();

As far as editing an item, your script looks to be doing what it needs to, but I'm guessing the actual date value is not something Sitecore recognized for a Date type field. Depending on the date format your CSV contains, you will likely need to utilize the Sitecore.DateUtil class to parse it into something that field can accept:

$currentItem.Editing.BeginEdit()
$csvDate = [DateTime]::ParseExact($row."publish date","dd/MM/yyyy HH:mm:ss",[Globalization.cultureinfo]::GetCultureInfo("en-US"))
$currentItem["Publish Date"] = [Sitecore.DateUtil]::ToIsoDate($csvDate)
$currentItem.Editing.EndEdit();
Source Link
vandsh
  • 1.7k
  • 11
  • 17

As far as editing an item, your script looks to be doing what it needs to, but I'm guessing the actual date value is not something Sitecore recognized for a Date type field. Depending on the date format your CSV contains, you will likely need to utilize the Sitecore.DateUtil class to parse it into something that field can accept:

$currentItem.Editing.BeginEdit()
$csvDate = [DateTime]::Parse($row."publish date")
$currentItem["Publish Date"] = [Sitecore.DateUtil]::ToIsoDate($csvDate)
$currentItem.Editing.EndEdit();