Is there a way to change a custom property of several views in bulk ?
Our customer Panasonic Airlines needs to change a customer property of > 1000 views, so …
Hi,
Maybe automation can help you achieve this.
This automation script below should do the trick(please test it first on a limited setup).
Note that this is an internal call and we do not recommend using this, as it is not officially supported and we cannot guarantee that it will still work in the future. As a rule, you should avoid using SLNet calls, as these are subject to change without notice. We recommend to instead always use the correct UI or automation options provided in DataMiner Automation or through our web API.
using Skyline.DataMiner.Automation;
using Skyline.DataMiner.Net.Messages.Advanced;
using Skyline.DataMiner.Net;
using Skyline.DataMiner.Net.Messages;
using System;
using System.Collections.Generic;
public class Script
{
public void Run(Engine engine)
{
ViewInfoEventMessage[] allViews = GetViews();
if(allViews == null)
{
engine.ExitFail("No views were found");
}
foreach(ViewInfoEventMessage view in allViews){
// do the filtering of views you want to update
if(view.Name.Equals("Temp"))
{
UpdateViewProperty(view,"PROPERTY YOU WANT TO UPDATE","NEW PROPERTYVALUE",engine);
}
}
}
public void UpdateViewProperty(ViewInfoEventMessage view, string propertyName, string propertyValue, Engine engine)
{
SetDataMinerInfoMessage request = new SetDataMinerInfoMessage();
request.bInfo1 = Int32.MaxValue;
request.bInfo2 = Int32.MaxValue;
request.DataMinerID = -1;
request.ElementID = -1;
request.HostingDataMinerID = -1;
request.IInfo1 = Int32.MaxValue;
request.IInfo2 = Int32.MaxValue;
SA sa = new SA();
sa.Sa = new String[] { propertyName, "read-write", propertyValue };
PSA psa = new PSA();
psa.Psa = new SA[] { sa };
request.Psa2 = psa;
request.StrInfo1 = $"view:{view.ID}";
request.What = 62;
SetDataMinerInfoResponseMessage response = engine.SendSLNetSingleResponseMessage(request) as SetDataMinerInfoResponseMessage;
if (response.iRet != 0)
{
engine.GenerateInformation($"Update of property {propertyName} on View {view.Name} was not OK");
}
}
public ViewInfoEventMessage[] GetViews()
{
var getViewsList = new GetInfoMessage
{
DataMinerID = -1,
Type = InfoType.ViewInfo
};
DMSMessage[] dmsma = Engine.SLNet.SendMessage(getViewsList);
if (dmsma == null)
{
return null;
}
return Array.ConvertAll(dmsma, input => (ViewInfoEventMessage)input);
}
}
Regards,
Hi Cristel,
I am afraid that currently this is not possible. At the moment, you can update one view property at the time.
In 10.1.9.0, there will be a new feature that will allow you to create views in bulk. However, this feature will not cover the update of view properties in bulk. In case you consider this feature required, please could you add this request in Feature Suggestion?
I used the script above to succesfully modify a property value of a view. As a next step I would like to update the value whenever the severity of the view changes. The value should be the Display Value of the severity. To trigger the script I would set up a correlation rule, that triggers
My assumption is that I would have to replace the "NEW PROPERTYVALUE" by a variable and dynamically update this variable with the severity of the view.
{
UpdateViewProperty(view,"PROPERTY YOU WANT TO UPDATE","NEW PROPERTYVALUE",engine);
}
Is there someone, who could support me with getting the Alarm state of a view and assign it to a variable in my script? Maybe there is an easy method for this available?