Alarm Pipeline Notification Calculated Roster: access pipeline properties

I have an alarm notification profile that has been setup as per the Escalation pipeline in the user manual (https://docs.inductiveautomation.com/display/DOC79/Pipeline±+Escalation)

Instead of sending an SMS to all users within a roster at once, I want to send an SMS to each user in the roster sequentially after the delay period. E.g. if i have 3 users in the roster, then numCalls would need to increment from 0 to 2 and the pipeline would SMS user 1, wait, then user 2, wait, then user 3, wait, then finally move on to the next escalation.

I presume this must be done as a calculated roster that will return only one contact dictionary at a time each time the notification block is called, incrementing the user each time it is called.

So I have some test code so far in the Notification → Contact → Calculated roster type script:

users = []
users.append({"username":"Nick", "phone":["22222222222"]})
users.append({"username":"Bob", "phone":["1111111111111"]})
userIndex = event.source.numCalls
roster = [users[userIndex]]
return roster

and this pipeline:

However, userIndex = event.source.numCalls doesn’t work as event is the alarm event, rather than the alarm pipeline object…

How can I access the numCalls property of the pipeline within this function?

Cheers!
Nick

Nevermind, I have the dumb…

‘event’ is a PyAlarmEvent object which has a ‘get’ method to access the alarm pipeline’s properties.

E.g. I can use event.get(‘numCalls’) to get the current numCalls value.

Hi,
Only for information:
A system.db.runNamedQuery NOT WORKS into Roster calculated mode.
I change the query to:
system.db.runQuery
And it goes right.
If someone else try it and could solve the issue, please, let me know.

2 Likes

Also adding information for reference:

While system.db.runNamedQuery does not work in a notification block's calculated roster script, you can do the following:

  • Call system.db.runNamedQuery in a script block
  • Store the result in an event prop
  • Reference that prop in the notification block

For example, on the script block:

results = system.db.runNamedQuery('path/to/myQuery')
event.set('results', results)

and on the notification block's calculated roster script:

results = event.get('results')

It feels very plausible to me that runNamedQuery actually would work fine, you just need to specify the project name as the first argument (see the gateway scoped section):
https://docs.inductiveautomation.com/display/DOC81/system.db.runNamedQuery

We could absolutely fix that, though, so that the project name is assumed from context.

Poor choice of argument order. :frowning_face:

1 Like

8.3's coming, and I've got lots of leeway to right wrongs in scripting. Obviously backwards compatibility is important, but I'm hoping to make the whole system namespace a lot more clear and consistent.

5 Likes