I have a DOM instance that contains a list field which needs to be updated (items removed or added).
But I have many problems.
The first issue is that the filters return no results. I've tried logging the result of the sectionFilter and of the presetNameFilter, but both return 0.
The second issue I have is following the guide on updating a list value in an instance. I found the following help, but I'm having problems finding out how to integrate these in my use-case.
A domInstance.GetFieldValue function doesn't seem to be found if I try it in Visual Studio.
https://docs.dataminer.services/user-guide/Advanced_Modules/DOM/DOM_examples/DOM_Altering_values_of_a_DomInstance.html
I'm also looking in the 'Example: retrieving a list value', but there it starts from the section and not from the instance.
I think I'm mixing instances and sections in both cases somehow, but could use some help on this.
Hi Jeroen,
Your first filter returns null because you're using the section definition GUID (variable multiviewerSectionDefinition) in a DOM definition exposer. I guess that you'll have a better result if you use variable multiviewerDomDefinition instead.
Related to your 2nd problem you can get the needed section from your instance by using one of below methods.
var sectionGUID = "GUID of the section";
instance.Sections.First(x => x.SectionDefinitionID.Id == Guid.Parse(sectionGUID));instance.Sections.First(x => x.GetSectionDefinition().GetName() == "Name of the section");
Hi Jens, would you know what the error “The Section was not yet stitched to the SectionDefinition” mean when I try to execute the following line?
Section mySection = alarmMVPreset.Sections.First(x => x.GetSectionDefinition().GetName() == “MV Preset”);
Hi Jeroen, You first need to stitch de DOM instances before you can use names and other objects instead of GUIDs. You can do this with below code:
domHelper.StitchDomInstances(instances);
thanks, I got that part working.
I’ll now focus on the editing part of the list.
Hi Jeroen,
Jens answered the first question. But regarding the second issue, GetFieldValue is an extension method which is located in the Skyline.DataMiner.Net.Sections namespace, make sure you include it.
GetListFieldValue is located in the Skyline.DataMiner.Net.Apps.Sections.Sections namespace.
If that's not the issue we, make sure you have the latest nuget installed. In my automation script I have the latest prerelease nuget installed - Skyline.DataMiner.Dev.Automation 10.3.2.1
Thanks Benjamin.
I indeed needed to add these namespaces.
fyi,
I was able to get it working with following code. Thanks to everyone for helping out.
const string multiviewerSectionDefinition = “55de1c92-c5c3-4b62-95da-b22bfb8cecf1”;
const string multiviewerDomDefinition = “cb0d0301-6099-4714-b7fe-56954b34e6cf”;
const string presetNameFieldDescriptorID = “65f91abc-b98b-4a47-bd91-6c35412e7d50”;
const string channelListFieldDescriptorID = “51c6658c-adee-4444-a78a-75b160b4bad5”;
var mvHelper = new DomHelper(engine.SendSLNetMessages, “multiviewermanagement”);
var sectionFilter = DomInstanceExposers.DomDefinitionId.Equal(new DomInstanceId(new Guid(multiviewerDomDefinition)));
var presetNameFilter = DomInstanceExposers.FieldValues.DictDynamicListField(presetNameFieldDescriptorID).Equal(“Alarm”);
var fullFilter = sectionFilter.AND(presetNameFilter);
var alarmMVPresets = mvHelper.DomInstances.Read(fullFilter);
engine.GenerateInformation(“amount found :”+ alarmMVPresets.Count);
mvHelper.StitchDomInstances(alarmMVPresets);
foreach(DomInstance alarmMVPreset in alarmMVPresets)
{
engine.GenerateInformation(“DOM Instance Name : ” + alarmMVPreset.Name);
Section mySection = alarmMVPreset.Sections.First(x => x.GetSectionDefinition().GetName() == “MV Preset”);
engine.GenerateInformation(“section : ” + mySection.ID);
var fieldValue = mySection.GetFieldValueById(new FieldDescriptorID(new Guid(channelListFieldDescriptorID)));
engine.GenerateInformation(“type of field: ” + fieldValue.Value.Type.ToString() + ” ; field descriptor : ” + fieldValue.GetFieldDescriptor().Name);
var valueWrapper = fieldValue.Value as ListValueWrapper;
List actualList = valueWrapper.Values;
engine.GenerateInformation(“number of channels in preset: ” + actualList.Count);
}