Hi,
I'm trying to create an new DOM instance from an automation script. it has a few sections and fields. However there is only section with 4 fields that are non-optional. However i keep running into some issue that doesn't yield much information on where this issues arose.
Since i could figure out where this issue was coming from i tried a bit of skeleton code.
I tested this first on another DOM which only have one section. That worked when using the correct data types. Then I tried to create one in my DOM with multiple sections. however this keeps throwing this error (stacktrace):
(Script DOMAdd) Log Message: " at Skyline.DataMiner.Net.ManagerStore.CrudHelperComponent`1.CheckTraceData(TraceData traceData) at Skyline.DataMiner.Net.ManagerStore.CrudHelperComponent`1.InnerCreate(T obj, IAdditionalOperationMeta operationMeta) at Skyline.DataMiner.Net.ManagerStore.CrudHelperComponent`1.Create(T obj) at Script.Run(Engine engine)"
and this is the code i use for creating an now dom instance:
var mcrJobdomHelper = new DomHelper(engine.SendSLNetMessages, "mcr_jobs");
var mcrjobs = new DomInstance() { DomDefinitionId = new DomDefinitionId(Guid.Parse("d081d5ac-834b-45ca-a921-00d8db650f03")) };// Sections
var eventInformationSection = new CustomSectionDefinition() { ID = new SectionDefinitionID(Guid.Parse("47db2587-f627-4c1d-898d-3a9bb80dfbf7")) };// fields
var eventInformation_Name = new FieldDescriptor() { ID = new FieldDescriptorID(Guid.Parse("bd89d529-5d61-4e4a-9160-9931c8f1c614")) };
var eventInformation_StartTime = new FieldDescriptor() { ID = new FieldDescriptorID(Guid.Parse("3de10925-b8bc-40b9-b98b-0d41bad4f612")) };
var eventInformation_EndTime = new FieldDescriptor() { ID = new FieldDescriptorID(Guid.Parse("e1fefad9-dc3f-41e4-b9b8-6355a8cd7b6f"))};
var eventInformation_Customer = new FieldDescriptor() { ID = new FieldDescriptorID(Guid.Parse("c2703c0a-9967-46e4-9946-31262cd44e32"))};// Event Information
mcrjobs.AddOrUpdateFieldValue(eventInformationSection, eventInformation_Name, Convert.ToString("testfromautomation"));
mcrjobs.AddOrUpdateFieldValue(eventInformationSection, eventInformation_StartTime, Convert.ToDateTime(new DateTime(2022,11,21,14,00,00)));
mcrjobs.AddOrUpdateFieldValue(eventInformationSection, eventInformation_EndTime, Convert.ToDateTime(new DateTime(2022, 11, 21, 15, 00, 00)));
mcrjobs.AddOrUpdateFieldValue(eventInformationSection, eventInformation_Customer, Guid.Parse("b78bfed1-ab88-4ba8-b468-c4bb2c809f12"));
mcrJobdomHelper.DomInstances.Create(mcrjobs);
and the dumps from the client tool:
First section with the non-optional fields:
SectionDefinition:
Name:Event Information
ID:47db2587-f627-4c1d-898d-3a9bb80dfbf7
---
FieldDescriptorName: Name
FieldDescriptorID: bd89d529-5d61-4e4a-9160-9931c8f1c614
FieldType: String
Validators: (None)
---
FieldDescriptorName: Start Time
FieldDescriptorID: 3de10925-b8bc-40b9-b98b-0d41bad4f612
FieldType: DateTime
Validators: (None)
---
FieldDescriptorName: End Time
FieldDescriptorID: e1fefad9-dc3f-41e4-b9b8-6355a8cd7b6f
FieldType: DateTime
Validators: (None)
---
FieldDescriptorName: Job Status
FieldDescriptorID: e4bb7f36-98ce-4d82-b7de-ce18c92671c5
FieldType: GenericEnum`1<Int32>
Validators: (None)
---
FieldDescriptorName: Customer
FieldDescriptorID: c2703c0a-9967-46e4-9946-31262cd44e32
FieldType: Guid
Validators: (None)
---
FieldDescriptorName: Customer Reference
FieldDescriptorID: 07708217-b74d-4b76-a1bd-dee318676d1e
FieldType: String
Validators: (None)
---
FieldDescriptorName: Contact person
FieldDescriptorID: 330a316f-fd37-45b9-bf75-98efaf6f44b8
FieldType: Guid
Validators: (None)
---
FieldDescriptorName: Event Type
FieldDescriptorID: 63ae4684-e516-4d43-b777-49770b1730e2
FieldType: GenericEnum`1<String>
Validators: (None)
---
FieldDescriptorName: Event Notes
FieldDescriptorID: 36451eab-c170-4eac-afc7-d75cf892c055
FieldType: String
Validators: (None)
And the domdefinition:
DomDefinition:
ID:d081d5ac-834b-45ca-a921-00d8db650f03
DomBehaviorDefinition:( null )
---
SectionDefinitionLink: 47db2587-f627-4c1d-898d-3a9bb80dfbf7
---
SectionDefinitionLink: 281cbe38-9525-43c2-8b02-2fc3fc189c16
---
SectionDefinitionLink: 00907567-7b9c-4613-acd2-164e6e2b6174
---
SectionDefinitionLink: 41335d2f-25b7-4e5b-8bb4-36050fbc73a5
---
SectionDefinitionLink: 5088bb93-31c6-4790-9bd7-7b21c8d70c54
---
SectionDefinitionLink: 8e0390f0-c3e6-4c23-98e9-ca8ae303c92c
Hi Gerwin,
I cannot spot the issue at first sight, but it seems that a CrudFailedException was thrown by DataMiner. This is most of the time an indication the input data did not meet the requirements set by the configuration.
Every CrudFailedException contains a TraceData object that has more info on what exactly went wrong. When you output the message of the exception instead of the stacktrace, you should see a string representation of this TraceData.
It is also possible to retrieve this TraceData & apply some own logic to this. The third code example on the DomHelper docs page shows how you can do this: https://docs.dataminer.services/user-guide/Advanced_Modules/DOM/DomHelper_class.html
Also, every docs page of the different DOM types contains a chapter about what errors can be included in this TraceData object when doing actions on that type. For example, here is this chapter for the DomInstance: https://docs.dataminer.services/user-guide/Advanced_Modules/DOM/DOM_objects/DomInstance.html#errors
I expect that you'll find one of these errors in the TraceData & these should guide you to the root cause of the exception. Let me know if that would not be the case.
Great. This error suggests that there is a mismatch between the sections present on a DomInstance and the requirements set by the DomDefinition. The DomInstance should contain at least one Section for each required SectionDefinitionLink defined on the DomDefinition. Can you double check if the ‘IsOptional’ bool is set to ‘true’ for all the other (seemingly) optional SectionDefinitionLinks that you are not using in the DomInstance?
Yes i found an missed non-optional field, the tracedata show this.
not fixed yet but i do get at least an new helpfull message:
Error reason: SectionsUsedInDomInstanceDoNotMatchRequirementsOfDomDefinition