SDK - create Enumeration via SDK and link it to attribute type enumeration in an entity

0
My goals: First, I would like to create an enumeration via Mendix SDK. Second, link the enumeration to an entity, i.e. set enumeration as type for one attribute. What works so far, generated via SDK the following appears in the app: Enumeration with literals only “name” is filled. “caption” is blank Entity with one attribute “name” filled. type “enumeration” and which enumeration “Priority” is blank. Enumeration values is blank because “caption” is blank. The following screenshot shows the aim: My problems: I cannot set “caption” via SDK because it is type “texts.Text” and it does not work to cast “String” input to it. How can I set caption? (I tried to find it out by reading in DevDocs: https://apidocs.rnd.mendix.com/modelsdk/latest/classes/enumerations.EnumerationValue.html#__caption) See my implementation: const newLiteral = enumerations.EnumerationValue.createIn(newEnumeration); newLiteral.name = "High"; // works newLiteral.caption = "High"; // does not work I want to set enumeration as type for one attribute in an entity. Therefore, I thought about this code snippet which only set the type to enumeration, but not which enumeration should be connected. How can I set the specific enumeration e.g. “Priority” via SDK? domainmodels.EnumerationAttributeType.createInAttributeUnderType(newAttribute); https://apidocs.rnd.mendix.com/modelsdk/latest/classes/domainmodels.EnumerationAttributeType.html When I try to open my app, I get the following error [1]   Hopefully, you can give me some hints. Thank you very much for your help! Let me know if information is missing. [1] System.InvalidOperationException: An error occurred when trying to set the 'Enumeration' property of a Enumeration in a Domain model with ID 84776610-13b2-48cb-a265-d5e984d63129. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: Value cannot be null. (Parameter 'value') at Mendix.Modeler.DomainModels.EnumerationAttributeType.set_EnumerationId(EnumerationIdentifier value) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Core\DomainModels\Attributes\Types\EnumerationAttributeType.Generated.cs:line 42 --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions) at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index) at Mendix.Modeler.Storage.Operations.UnitContentsLoader.FillProperties(IStorageUnit containingUnit, IStorageObject obj, JObject jObject, ICachedType cachedType) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\Operations\UnitContentsLoader.cs:line 105 --- End of inner exception stack trace --- at Mendix.Modeler.Storage.Operations.UnitContentsLoader.FillProperties(IStorageUnit containingUnit, IStorageObject obj, JObject jObject, ICachedType cachedType) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\Operations\UnitContentsLoader.cs:line 110 at Mendix.Modeler.Storage.Operations.UnitContentsLoader.ConstructObjectInternal(IStorageUnit containingUnit, IStorageObject container, JObject jObject) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\Operations\UnitContentsLoader.cs:line 64 at Mendix.Modeler.Storage.Operations.UnitContentsLoader.ConvertFromStorage(IStorageUnit containingUnit, IStorageObject obj, ICachedProperty prop, JToken token) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\Operations\UnitContentsLoader.cs:line 137 at Mendix.Modeler.Storage.Operations.UnitContentsLoader.FillProperties(IStorageUnit containingUnit, IStorageObject obj, JObject jObject, ICachedType cachedType) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\Operations\UnitContentsLoader.cs:line 102 at Mendix.Modeler.Storage.Operations.UnitContentsLoader.ConstructObjectInternal(IStorageUnit containingUnit, IStorageObject container, JObject jObject) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\Operations\UnitContentsLoader.cs:line 64 at Mendix.Modeler.Storage.Operations.UnitContentsLoader.ConvertFromStorage(IStorageUnit containingUnit, IStorageObject obj, ICachedProperty prop, JToken token) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\Operations\UnitContentsLoader.cs:line 137 at Mendix.Modeler.Storage.Operations.UnitContentsLoader.FillProperties(IStorageUnit containingUnit, IStorageObject obj, JObject jObject, ICachedType cachedType) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\Operations\UnitContentsLoader.cs:line 97 at Mendix.Modeler.Storage.Operations.UnitContentsLoader.ConstructObjectInternal(IStorageUnit containingUnit, IStorageObject container, JObject jObject) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\Operations\UnitContentsLoader.cs:line 64 at Mendix.Modeler.Storage.Operations.UnitContentsLoader.ConvertFromStorage(IStorageUnit containingUnit, IStorageObject obj, ICachedProperty prop, JToken token) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\Operations\UnitContentsLoader.cs:line 137 at Mendix.Modeler.Storage.Operations.UnitContentsLoader.FillProperties(IStorageUnit containingUnit, IStorageObject obj, JObject jObject, ICachedType cachedType) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\Operations\UnitContentsLoader.cs:line 97 at Mendix.Modeler.Storage.Operations.UnitContentsLoader.ConstructObjectInternal(IStorageUnit containingUnit, IStorageObject container, JObject jObject) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\Operations\UnitContentsLoader.cs:line 64 at Mendix.Modeler.Storage.Operations.UnitContentsLoader.ConstructUnitFromContents(IStorageUnit container, Byte[] contents) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\Operations\UnitContentsLoader.cs:line 39 at Mendix.Modeler.Storage.Operations.UnitLoader.ConstructUnit(IStorageUnit container, DbDataReader reader) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\Operations\UnitLoader.cs:line 237 at Mendix.Modeler.Storage.Operations.UnitLoader.LoadUnits(IStorageUnit unit, IList`1 unitIDs) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\Operations\UnitLoader.cs:line 187 at Mendix.Modeler.Storage.Operations.UnitLoader.LoadChildUnits(IStorageUnit unit) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\Operations\UnitLoader.cs:line 131 at Mendix.Modeler.Storage.Operations.UnitLoader.LoadChildUnits(IStorageUnit unit) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\Operations\UnitLoader.cs:line 162 at Mendix.Modeler.Storage.Operations.UnitLoader.Load[T](IProgressInfo info, Dictionary`2 _knownUnits) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\Operations\UnitLoader.cs:line 48 at Mendix.Modeler.Storage.Database.Load[T](IProgressInfo info, Dictionary`2 knownUnits, Boolean throwOnUnknownObjects) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\Database.cs:line 202 at Mendix.Modeler.Operations.ProjectFileLoader.<>c__DisplayClass2_0.<Load>b__0(Database database) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Core\Operations\ProjectFileLoader.cs:line 29 at Mendix.Modeler.Storage.Database.<>c__DisplayClass24_0`1.<Do>b__0(IDbConnector connector) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\Database.cs:line 159 at Mendix.Modeler.Utility.DbConnectors.SQLiteConnector.<>c__DisplayClass3_0`1.<Do>b__1() in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\DbConnectors\SQLiteConnector.cs:line 44 at Mendix.Modeler.Utility.DbConnectors.DbConnector.WithoutTransactionDo[TResult](Func`1 action) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\DbConnectors\DbConnector.cs:line 65 at Mendix.Modeler.Utility.DbConnectors.SQLiteConnector.Do[TResult](String filePath, Boolean useTransaction, Func`2 action) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\DbConnectors\SQLiteConnector.cs:line 42 at Mendix.Modeler.Storage.Database.Do[TResult](String filePath, Boolean useTransaction, Func`2 action) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Storage\Database.cs:line 159 at Mendix.Modeler.Operations.ProjectFileLoader.Load(IProgressInfo info, String filePath, Boolean debugLogEnabled) in C:\Users\Autobuild\workspace\AppStudio4.0-Build\modeler\Mendix.Modeler.Core\Operations\ProjectFileLoader.cs:line 25  
asked
0 answers