Alarm Pipeline - Notify multiple rosters dynamically

I have an application where both individual users and rosters can be assigned to a particular alarm at run time. For the individual users, I achieved this with a calculated roster that reads in my list of assigned users (a custom property on the tag) and uses the system functions to get the user objects and the contact info from the gateway for each user, then the builder to assemble the result roster.

I have a similar list of rosters, also a custom property on the tag. I want to dynamically notify any number of rosters based on that list, and also avoid duplicating notifications if a user belongs to more than one of the chosen rosters.

My first idea is to use a calculated roster again, and in scripting build the new roster by combining all the users of the individual chosen rosters and remove/avoid duplicates in that scripting. Is the the only or best way of doing this?

As I was making this post I came across this thread: Alarm Pipeline - Array of rosters showing how to loop through a list of rosters with a single notification block being called for however many rosters are in the list. This is very close to what I need, but I still think would result in the multiple notification issue?

Your idea to use a calculated roster via scripting works well. Looking at that project you shared, I agree that would result in multiple notifications.

I was able to do the merge easily in scripting,might be helpful others trying to do the same. After merging the desired rosters I can grab the contact info for each user and use the builder to generate the final roster for the notification.

Note: The function system.alarm.getRosters() is used for testing in script console, will need to change to system.roster.getRosters() when used in perspective - see note here.

# Input = List of roster names to merge
# Returns = List of users contained by these rosters, without duplicates.
def mergeRosters(rosters):
	users = set()
	allRosterData = system.alarm.getRosters()	# Contains rosters and each roster's users
	
	for roster in rosters:
		users = set(users+allRosterData[roster])
	
	return list(users)

# Test code...
mergedUserList = mergeRosters(["Test Roster 2", "Test Roster 3", "Maintenance"])
print mergedUserList