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,
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);
}