Hello,
I tried to use the GetActiveAlarmsMessage to fetch all alarms and filter them by a custom property. I found how to implement filtering by various fields through other dojo questions, but I'm struggling getting the filter to work for my custom property.
Here's how it looks:
var alarmFilterItem = new AlarmFilterItemString(AlarmFilterField.PropertyValue, "Alarm.CMDB System", AlarmFilterCompareType.Equality, new[] { "SNOW", "Automatic" });
var message = new GetActiveAlarmsMessage(-1)
{
Filter = new AlarmFilter(alarmFilterItem),
};
I read in the answers of this question that I need a prefix before the property name to specify it's source. I'm not sure if the prefix for custom properties is different, or it's not possible at all as I get a result with 0 alarms with the displayed request.
Any help is appreciated!
Hi Benjamin,
I performed a small test using a modified version of this ad-hoc data source SLC-GQIDS-ActiveAlarmsUsingFilter, and I was able to successfully retrieve an active alarm that matches the specified filter criteria. Below is a snippet of the modified version for your reference:
string propertyName = "Alarm.ClassAlarm";
string propertyValue = "Gold";var alarmFilterByProperty = new AlarmFilterItemString(AlarmFilterField.PropertyValue, propertyName, AlarmFilterCompareType.Equality, new[] {propertyValue} );
var filter = new AlarmFilter(filterItems: new AlarmFilterItem[] { alarmFilterByProperty });
var msg = new GetActiveAlarmsMessage() { Filter = filter };var alarmsResponse = engine.SendSLNetSingleResponseMessage(msg) as ActiveAlarmsResponseMessage;
if (alarmsResponse != null)
{
return alarmsResponse.ActiveAlarms.WhereNotNull().ToList();
}
The alarm that I am using for my test:
And the result:
Hope it helps.
Hi Miguel, thanks for taking the time to test this.
By displaying my property in the alarm console, just like you did, I found out that the alarm inherited it from the service, which means that my filter should have started with the prefix "Service.". That way it works.
Thank you!