Hello Dojo community,
I have a requirement to edit (CRUD) instances of exiting Dataminer Object Model programmatically from within a custom API automation script.
I found the following references:
https://docs.dataminer.services/develop/api/types/Skyline.DataMiner.Utils.DOM.html
https://docs.dataminer.services/develop/api/types/Skyline.DataMiner.Utils.DOM.Builders.html
The way I understand it, to i.e. create a new instance I need to do the following:
DomCache dom = new DomCache(messageHandler, moduleId);
DomHelper helper = dom.Helper;
DomInstanceBuilder domInstanceBuilder = new DomInstanceBuilder();
domInstanceBuilder.WithID(guidId);
DomInstance newDomInstance = domInstanceBuilder.Build();
newDomInstance.SetFieldValue("SectionName", "FieldName", "Initial Value", dom);
DomInstanceCrudHelperComponent instanceCrudHelp = helper.DomInstances;
instanceCrudHelp.Create(newDomInstance);
Questions:
- Is this the correct/optimal way?
- How can GUID for the new instance be auto generated?
- What is the recommended implementation of the MessageHandler method passed via the Func delegate when creating the DomCache object.
Many thanks.
Pawel.
Hi Pawel,
Let me try to answer your questions:
- Your code will probably work, but better would be to construct the whole object before calling the Build() method. The SetFieldValue method can be replaced by the WithFieldValue() method on the builder itself.
- If you don't set a GUID yourself using the SetID() method, a random GUID will be assigned to the DOM instance.
- The MessageHandler delegate defines a way to send and receive SLNet messages for communication from the DMA.
- In an automation script it can be used as follows: new DomCache(engine.SendSLNetMessages, "module").
- In a connector: new DomCache(protocol.SLNet.SendMessages, "module").
Please let me know if there are further questions.
Kind regards,
Tom
You’re welcome! I’m glad I could help.
Hi Tom,
Many thanks for the answers.