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 1346 posts 4453 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 12133 karma points MVP 8x 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 1346 posts 4453 karma points c-trib
    Oct 03, 2023 @ 14:49
    Steve Morgan
    0

    Perfect!

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

Please Sign in or register to post replies

Write your reply to:

Draft