Add / update an alarm notes via code / API

Hello,

I need to add notes or update an existing one for alarm.

I know I get can notes via API / code but I did not find any way to overwrite the data from code or API.

 For example this code will get alarms notes:

alarmId = args['alarmId']
alarmService = server.get('AlarmService');
topSrv = server.get('TopologyService');
annos = alarmService.getAnnotations(alarmId);
alarmNotes = [];
for(anno in annos){
        note = topSrv.createAnonymousDataObject(topSrv.getType('AlarmNote'));
	note.set("id", anno.getID());
	note.set("text", anno.getText());
	note.set("alarmId", alarmId);
	note.set("username", anno.getUsername());
	note.set("createdTime", anno.getCreatedTime());
	alarmNotes.add(note);
}
return alarmNotes;

when I try to set the text of the notes it will not update in Foglight database, there is a way to use code to set the data that will save in the system?

Thanks.

Parents
  • we use this to set a unique note, you'll have to set the args yoursef of course

    not sure if it helps:

    def alarmID = args[1]
    def text = args[2]		
    def annotations = server["AlarmService"].getAnnotations(alarmID)
    def exists = annotations. find {it.text.equals(text)}
    if(!exists){
     	server.AlarmService.createAnnotation ( text as String, alarmID)
    }

Reply
  • we use this to set a unique note, you'll have to set the args yoursef of course

    not sure if it helps:

    def alarmID = args[1]
    def text = args[2]		
    def annotations = server["AlarmService"].getAnnotations(alarmID)
    def exists = annotations. find {it.text.equals(text)}
    if(!exists){
     	server.AlarmService.createAnnotation ( text as String, alarmID)
    }

Children