Hi,
I'm trying to get information of an DOM instance from an automation script. I'll trigger that script through an low code app and pass the guid of the instance i need to open in the automation script.
Looking at the examples on https://docs.dataminer.services/user-guide/Advanced_Modules/DOM/DOM_examples/DOM_status_system_example.html
there mainly focused on creating and updating fields, but little to no information about reading the information based on having an valid instance guid.
Hi Gerwin,
Below some code examples in case the script is executed from a DOM button in a Low code app.
Load basics
var instanceId = context.ContextId as DomInstanceId;
var domHelper = new DomHelper(engine.SendSLNetMessages, instanceId.ModuleId);
DomInstance domInstance = GetDomInstance(domHelper, instanceId);private static DomInstance GetDomInstance(DomHelper domHelper, DomInstanceId instanceId)
{
FilterElement<DomInstance> domInstanceFilter = DomInstanceExposers.Id.Equal(instanceId);List<DomInstance> domInstances = domHelper.DomInstances.Read(domInstanceFilter);
domHelper.StitchDomInstances(domInstances);return domInstances.First();
}
Go through Sections > FieldValues and store the data in an object
foreach (var section in domInstance.Sections)
{
foreach (var fieldValue in section.FieldValues)
{
var fieldDescriptor = fieldValue.GetFieldDescriptor();
switch (fieldDescriptor.Name)
{
case "Field Descriptor Name":
data.Name = Convert.ToString(fieldValue.Value.Value);
break;default:
break;
}
}
}
Took some fiddeling but it does work 🙂 thanks!