How to get event detector default message as a variable?
-
Hello!
We are using "evt.context.pointEventDetector.xid " to get the xid of an event. Also, we want to use default message (which is shown on event view.). Is that possible to get event default message like xid? If possible, can you please share the format?
//to get event xid : var parameter = evt.context.pointEventDetector.xid; //Thanks a lot
-
@Nurr it looks like you want to do this in a Mango JavaScript context. Next time be more clear as to exactly what and how you are trying to do something so I don't have to make assumptions.
I assume this is an Email event handler's script and you have already found how to get the event into your
evt
variable. I believe there are 2 ways to get this:var messageString = evt.messageString; var translatableMessageObject = evt.message;
The translatable message object is used throughout Mango to represent an untranslated String. Assuming you are ok with using the Mango server locale to translate the message you can just use the messageString as it will be human readable.
This is the java class that is bound to the script context:
-
Re: How to get event detector default message as a variable?
Hi @terrypacker!
Thanks for your help!! This is a set point event handler. Next time I'll be more clear.
The one in below works for me.var message = evt.messageString.toString();
-
@terrypacker Additionally, can I get the data source IP of the relevant event?
For datasource name, I'm using ;
var dataSourceName= evt.context.point.dataSourceName;
Thanks in advance!
-
@Nurr getting the data source configuration will be slightly more complex but possible. Basically you will need to reach out to the Mango database by using the DataSourceDao class to get the data source configuration. The
evt
variable does not contain the full data source but it does have the data source's id which you can use to get the full data source. Here is an example//Option 1 get the data source id from the event type var id = evt.eventType.dataSourceId; //Option 2 get the id from the point in the context var id = evt.context.point.dataSourceId; //Using a call to the dao, get the data source by id var dataSource = com.serotonin.m2m2.db.dao.DataSourceDao.instance.getDataSource(id);
Without knowing which data source type you are using I cannot tell you what property the ip would be stored in. It may be open source in our ma-modules-public repository, if so you can find the property in the xxxDataSourceVO class:
https://github.com/infiniteautomation/ma-modules-public