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

    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 );
  • samay 22 posts 132 karma points
    Mar 13, 2018 @ 02:07

    In case someone to looking for this

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

    Hi Samay

    Thanks for sharing, really nice tip! #h5yr

Please Sign in or register to post replies

Write your reply to: