Copied to clipboard

Flag this post as spam?

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


  • samay 22 posts 132 karma points
    Mar 12, 2018 @ 10:16
    samay
    1

    How can I set vorto value to content via code ?

    I try to bulk create the content, one of the property is a vorto textstring

    here is the code, when call the SetValue content an error occur

    "UMBRACO The best overloaded mthod match for 'Umbraco.Core.Models.ContentBase.SetPropertyValue(string, string)' has some invalid arguments"

    anybody can help with this, thanks a lot

    var cs = _applicationContext.Services.ContentService;
    var dts = _applicationContext.Services.DataTypeService;
    Guid vortoTextstringGuid = dts.GetAllDataTypeDefinitions().Where(x => x.Name == "Vorto Textstring").FirstOrDefault().Key;
    
    var newContent = cs.CreateContent(name: "newItem, parentId: 6500, contentTypeAlias: "itemTypeAlias", userId: 0);
    
    
    VortoValue newVortoItem = new VortoValue();
     newVortoItem.Values = new Dictionary<string, object>();
                            department.Values.Add("en-US", (object)"English");                        
                            department.Values.Add("zh-HK", (object)"Chinese");
    newContent.SetValue("ItemPropTypeAlias", (object)newVortoItem );
    
    cs.Save(newContent);
    
  • samay 22 posts 132 karma points
    Mar 13, 2018 @ 02:07
    samay
    103

    In case someone to looking for this

    newContent.SetValue("ItemPropTypeAlias", JsonConvert.SerializeObject(newVortoItem ));
    
  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Mar 13, 2018 @ 10:37
    Alex Skrypnyk
    0

    Hi Samay

    Thanks for sharing, really nice tip! #h5yr

Please Sign in or register to post replies

Write your reply to:

Draft