Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • npack 49 posts 295 karma points
    Aug 16, 2024 @ 15:16
    npack
    0

    DateTime vs DateTimeOffset - Umbraco v14 Error. Anyone seen this one?

    Has anyone run into this one?

    I have a property on a document type that is a datepicker. It has a value.

    After I upgraded to v14 I can't open that document in the document editor anymore.

    System.InvalidOperationException: Cannot assign value "5/29/2024 12:00:00 PM -06:00" of type "System.DateTimeOffset" to property "endDate" expecting type "System.DateTime".
    

    My generated document class still has the .NET datatype as a DateTime. Usync dumpts the the value as "2024-05-29T12:00:00" But it sounds from the error message as if the value is being seen-as or converted to a DateTimeOffset then struggling to go back again to DateTime.

    System.InvalidOperationException: Cannot assign value "5/29/2024 12:00:00 PM -06:00" of type "System.DateTimeOffset" to property "endDate" expecting type "System.DateTime".
       at Umbraco.Cms.Core.Models.Property.ThrowTypeException(Object value, Type expected, String alias)
       at Umbraco.Cms.Core.Models.Property.TryConvertAssignedValue(Object value, Boolean throwOnError, Object& converted)
       at Umbraco.Cms.Core.Models.Property.ConvertAssignedValue(Object value)
       at Umbraco.Cms.Core.Models.Property.SetValue(Object value, String culture, String segment)
       at Umbraco.Cms.Core.PropertyEditors.BlockValuePropertyValueEditorBase`2.MapBlockItemDataToEditor(IProperty property, List`1 items)
       at Umbraco.Cms.Core.PropertyEditors.BlockValuePropertyValueEditorBase`2.MapBlockValueToEditor(IProperty property, TValue blockValue)
       at Umbraco.Cms.Core.PropertyEditors.BlockEditorPropertyValueEditor`2.ToEditor(IProperty property, String culture, String segment)
       at Umbraco.Cms.Api.Management.Mapping.Content.ContentMapDefinition`3.<>c__DisplayClass4_1.<MapValueViewModels>b__1(IPropertyValue propertyValue)
       at System.Linq.Enumerable.SelectListIterator`2.MoveNext()
       at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
       at System.Linq.Enumerable.WhereEnumerableIterator`1.ToArray()
       at Umbraco.Cms.Api.Management.Mapping.Content.ContentMapDefinition`3.MapValueViewModels(IEnumerable`1 properties, ValueViewModelMapping additionalPropertyMapping)
       at Umbraco.Cms.Api.Management.Mapping.Document.DocumentMapDefinition.Map(IContent source, DocumentResponseModel target, MapperContext context)
       at Umbraco.Cms.Core.Mapping.UmbracoMapper.<>c__DisplayClass10_0`2.<Define>b__1(Object source, Object target, MapperContext context)
       at Umbraco.Cms.Core.Mapping.UmbracoMapper.Map[TTarget](Object source, Type sourceType, MapperContext context)
       at Umbraco.Cms.Core.Mapping.UmbracoMapper.Map[TTarget](Object source, MapperContext context)
       at Umbraco.Cms.Core.Mapping.UmbracoMapper.Map[TTarget](Object source)
       at Umbraco.Cms.Api.Management.Factories.DocumentPresentationFactory.CreateResponseModelAsync(IContent content)
       at Umbraco.Cms.Api.Management.Controllers.Document.ByKeyDocumentController.ByKey(CancellationToken cancellationToken, Guid id)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
    
  • npack 49 posts 295 karma points
    Aug 16, 2024 @ 15:34
    npack
    100

    Nevermind. Looks like it will be addressed in 14.2.0. Sweet.

    https://github.com/umbraco/Umbraco-CMS/issues/16795

Please Sign in or register to post replies

Write your reply to:

Draft