Copied to clipboard

Flag this post as spam?

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


  • Erik 11 posts 47 karma points
    Aug 13, 2016 @ 16:00
    Erik
    1

    Create new DataType from custom type trought DataTypeService. [Solved]

    Hi there. I am trying for an hour now to add a new datatype on ApplicationStartup.

    I tride a fiew option and I even browsed the source code and checked DataType/PostSave. When I tried to replicate the procedure I get

    The INSERT statement conflicted with the FOREIGN KEY constraint "FK_cmsPropertyType_cmsDataType_nodeId". The conflict occurred in database "umbraco-cms", table "dbo.cmsDataType", column 'nodeId'.
    

    Currently this is my code.

                      // dt DataType feched from service 
                      if (null == dt)
                        {
                            var df = Mapper.Map<IDataTypeDefinition>(new DataTypeSave()
                            {
                                Action = ContentSaveAction.SaveNew,
                                ParentId = -1,
                                Id = 0,
                                SelectedEditor = "MediaPublish.Versions",
                                Name = "Media Version",
                                PreValues = new List<PreValueFieldSave>()
                            });
    
                            dType.SaveDataTypeAndPreValues(df, new Dictionary<string, PreValue>());
                        }
    

    I really need help.

    Solved.. I only had to ask.. and I found the solution hidden in plain sight.

    https://github.com/vegaitsourcing/uSiteBuilder/blob/master/source/Vega.USiteBuilder/DataTypeBuilder/DataTypeManager.cs

Please Sign in or register to post replies

Write your reply to:

Draft