Skip to content
DataMiner DoJo

More results...

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Search in posts
Search in pages
Search in posts
Search in pages
Log in
Menu
  • Blog
  • Questions
  • Learning
    • Courses
    • Certification
      • DataMiner Operator
      • DataMiner Administrator
      • DataMiner Automation
      • Scripts & Connectors Developer: HTTP Basics
      • Scripts & Connectors Developer: SNMP Basics
      • Visual Overview – Level 1
    • Video Library
    • Books We Like
    • Third-party Courses
    • DevOps Enablement Services
    • Quizzes
  • RESOURCES
  • Agile
    • Agile Webspace
    • Everything Agile
      • The Agile Manifesto
      • Best Practices
      • Retro Recipes
    • Methodologies
      • The Scrum Framework
      • Kanban
      • Extreme Programming
    • Roles
      • The Product Owner
      • The Agile Coach
      • The Quality & UX Coach (QX)
  • Expert Hubs
    • DataMiner DevOps Professional Program
    • DataMiner
      • DataMiner Releases & Updates
      • System Architecture
      • Integration Studio
      • Visual Overview
      • Security
    • Technologies
      • CI/CD
      • Converged Interconnect Networks
      • DOCSIS 3.1 / DAA
      • Elasticsearch
      • Kubernetes
      • Telemetry / Flow Monitoring
      • PTP
      • SDN / ST2110 / NMOS
    • Business
      • Software Business models
      • Perpetual Use or Usage-based Services
  • Discover
    • Markets
      • Media production
      • Government & defense
      • Content distribution
      • Service providers
      • Partners
      • OSS/BSS
    • Solutions
    • Use Case Library
    • DataMiner Dashboards
    • DataMiner Downloads
    • DataMiner Modules
      • Core features
      • SRM features
    • DataMiner Apps
    • Professional Services
  • PARTNERS
    • All Partners
    • Technology Partners
    • Strategic Partner Program
    • Deal Registration
  • Pricing
  • More
    • Feature Suggestions
    • Online DataMiner Systems
    • Leaderboard
    • Swag Shop
    • Contact
      • General Inquiries
      • DataMiner DevOps Support
      • Commercial Requests
    • Global Feedback Survey
    • Verify a certificate
  • >> Go to dataminer.services

Automation script for DOM instances: retrieving instances by guid

Solved136 views5th July 2023DOM
4
Jeroen Geldhof [SLC] [DevOps Enabler]3.44K 5th July 2023 0 Comments

I looked into the documentation, but it's not clear how to retrieve an instance using a guid as an input.
Next I'd also like to retrieve a field value from that instance object.

I already have a DomHelper object.  So far so good.
Any ideas on how to go about the rest?

Jeroen Geldhof [SLC] [DevOps Enabler] Selected answer as best 5th July 2023

2 Answers

  • Active
  • Voted
  • Newest
  • Oldest
6
Matthias Declerck [SLC] [DevOps Enabler]1.82K Posted 5th July 2023 0 Comments

Hi Jeroen,

Let me quickly give you few pseudo code snippets (C# blocks):

GET DOM INSTANCE

// Retrieve the DomInstance
var helper = new DomHelper(engine.SendSLNetMessages, "MODULE ID");
var filter = DomInstanceExposers.Id.Equal(<DOM INSTANCE ID>);
var domInstance = helper.DomInstances.Read(filter).FirstOrDefault();

GET FIELD OF DOM INSTANCE (follow up on code block above)

 
var instanceField = domInstance.Sections?.FirstOrDefault().GetFieldValueById(< DOM DESCRIPTOR ID >);
object instanceValue = instanceField?.Value.Value;

Note: I assume it is better to for-loop the sections list.

Documentation: Altering values of a DomInstance - examples | DataMiner Docs

Hope this helps you further

Jeroen Geldhof [SLC] [DevOps Enabler] Selected answer as best 5th July 2023
4
Ive Herreman [SLC] [DevOps Enabler]7.39K Posted 5th July 2023 0 Comments

Hi Jeroen,

You can find some sample code below.
Note that I've hard-coded the section definition id and field descriptor id.

Ideally you store the ids in a separate class to make the code more readable.

public void Run(IEngine engine)
{
try
{
Guid domInstanceId = new Guid(engine.GetScriptParam("Dom Instance ID").Value);

DomInstance domInstance = GetDomInstance(engine, domInstanceId);

string myValue = GetSectionField<string>(domInstance, new SectionDefinitionID(new Guid("7a1fb82e-44be-4c27-a7ab-60b83417bf7a")), new FieldDescriptorID(new Guid("5506da8b-9af0-43df-9c81-4a0bb2bed851")));
engine.GenerateInformation($"Value: {myValue}");

}
catch (Exception ex)
{
engine.GenerateInformation($"Error: {ex}");
engine.ExitFail(ex.ToString());
}
}

public static DomInstance GetDomInstance(IEngine engine, Guid domInstanceId)
{
var domHelper = new DomHelper(engine.SendSLNetMessages, "lab_hq");

FilterElement<DomInstance> domFilter = DomInstanceExposers.Id.Equal(domInstanceId);
return domHelper.DomInstances.Read(domFilter).SingleOrDefault();
}

public static T GetSectionField<T>(DomInstance domInstance, SectionDefinitionID sectionDefinitionId, FieldDescriptorID fieldDescriptorId)
{
var section = domInstance.Sections.SingleOrDefault(x => x.SectionDefinitionID.Id == sectionDefinitionId.Id);

if (section == null)
{
return default(T);
}

var flowsField = section.FieldValues.SingleOrDefault(x => x.FieldDescriptorID.Id == fieldDescriptorId.Id);

if (flowsField == null)
{
return default(T);
}

return (T)flowsField.Value.Value;
}

Ive Herreman [SLC] [DevOps Enabler] Answered question 5th July 2023
Please login to be able to comment or post an answer.

My Dojo Points

0 Credits
0 Reputation

Question Tag Cloud

adl2099 (54) Alarm Console (53) alarms (69) alarm template (58) API (34) Automation (143) automation scipt (65) Automation script (95) backup (54) Cassandra (141) cloud (36) Connector (44) Correlation (42) Cube (114) Dashboard (134) Dashboards (134) database (64) DataMiner Cube (37) DIS (53) DMS (48) DOM (66) driver (48) DVE (43) Elastic (73) Elasticsearch (99) elements (49) Failover (90) GQI (49) HTTP (45) IDP (54) low code app (68) low code apps (42) MySQL (50) protocol (145) QAction (56) resources (34) security (71) SNMP (55) SRM (266) SRM resources (37) timeout (35) trending (66) upgrade (44) Visio (370) Visual Overview (290)
Privacy Policy • Terms & Conditions • Contact

© 2023 Skyline Communications. All rights reserved.

[ Placeholder content for popup link ] WordPress Download Manager - Best Download Management Plugin