Copied to clipboard

Flag this post as spam?

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


  • Steve Morgan 1350 posts 4460 karma points c-trib
    Oct 03, 2023 @ 12:47
    Steve Morgan
    0

    Update datatype configuration programmatically - set StartNodeId

    I'm trying to update a media picker v3 start node. Does anyone know how to do this?

    I've got this far:

    var curDataType = _dataTypeService.GetDataType("SteveTest");
    
    var curConfiguration = (Umbraco.Cms.Core.PropertyEditors.MediaPicker3Configuration)(curDataType.Configuration);
    
    curConfiguration.StartNodeId = Udi.Create(Constants.UdiEntityType.Media, Guid.Parse("cf7caaed6477472f9ef157f808f9a15e"));
    
    curDataType.Configuration = curConfiguration;
    

    This gives me: System.ArgumentException: 'Configurations are kinda non-mutable. Do not reassign the same object. (Parameter 'value')'

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Oct 03, 2023 @ 13:12
    Dave Woestenborghs
    100

    Hi Steve,

    Maybe you can try this :

    var curDataType = _dataTypeService.GetDataType("SteveTest");
    
    ((Umbraco.Cms.Core.PropertyEditors.MediaPicker3Configuration)curDataType.Configuration).StartNodeId =  Udi.Create(Constants.UdiEntityType.Media, Guid.Parse("cf7caaed6477472f9ef157f808f9a15e"));
    
  • Steve Morgan 1350 posts 4460 karma points c-trib
    Oct 03, 2023 @ 14:49
    Steve Morgan
    0

    Perfect!

    Of course - sometimes you just need to really read the error :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies