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.
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
Currently this is my code.
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
is working on a reply...