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 113 karma points
    1 week ago

    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 113 karma points
    1 week ago

    In case someone to looking for this

    newContent.SetValue("ItemPropTypeAlias", JsonConvert.SerializeObject(newVortoItem ));
  • Alex Skrypnyk 4409 posts 15799 karma points MVP
    1 week ago
    Alex Skrypnyk

    Hi Samay

    Thanks for sharing, really nice tip! #h5yr

Please Sign in or register to post replies

Write your reply to: