This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Function output type error

I'm trying to create a function that takes a ruleId and returns all of the alarms(not just the current ones) in the past week for that rule.  When I try to test it I get the following error:

 

the value returned by the Script: "Static value of type: "com.quest.nitro.service.alarm.AlarmImpl"" is not assignable to the Script output type: "foglight-5:Alarm"

 

This is the code I'm using for the function.

 

package system._customdashboards.scripts;
// This script comes with no support, expressed or implied.
import com.quest.nitro.service.alarm.*;
import com.quest.nitro.service.sl.interfaces.alarm.*;
import groovy.time.*;

topSvc = server.get("TopologyService");
almSvc = server.get("AlarmService");
rulSvc = server.get("RuleService");


use (TimeCategory)
{

	dateEnd = new Date();
	dateStart = dateEnd - 1.week;

	alarms = almSvc.getAlarms(dateStart, dateEnd);
}


return alarms.findAll{it.getRuleID() == AlarmCountInput.ruleID};

 

 I have the Output Data type set to Monitoring:Alarm.  I this the wrong type?  Is there some way to convert com.quest.nitro.service.alarm.AlarmImpl to foglight-5:Alarm? 

  • I replaced the line

    return alarms.findAll{it.getRuleID() == AlarmCountInput.ruleID};

     

    with

    alarmList = [];
    alarms.findAll{
    		it.getRuleID() == AlarmCountInput.ruleID
    	}.each{a->
    	
    		alarmList.add(server.UIQueryService.wrapDataObject("Alarm", a));	
    	};
     
    return alarmList;


    Apparently the line:
    server.UIQueryService.wrapDataObject("Alarm", a)

    wraps the alarm in the correct type.