Filtering Roster based on User Role

I am working on a project and have come to a crossroads of how to set up user management and On-Call Rosters for the alarm pipeline. There are different zones, Hatchery, Nursery, etc. We have all the tags on different tag providers that are the same as their zone name. The issue is that to setup the alarm pipelines with escalation and zone filtering it seems as if we would need up to 5 different rosters for each zone, which will end up having a large number of rosters. What I am looking to see is if it is possible to filter the users in a roster based on their role. For instance, I would have 5 rosters named Escalation Tier 1-5 and depending on the user role it will be sent to only the users that have the defined roles inside of that roster.

Depending on a bunch of things, I might store users in a database table with columns specific to your use case, then pull them in a calculated roster.
The “bunch of things” includes, but is not limited to:

  • who configures those rosters
  • can users be in multiple rosters
  • how the roles are used in the selection process

I worked with Ignition Support to come up with a solution, if anyone else has a use case for this here is what we came up with. Below is the calculated roster that does role and roster filtering inside of a notification block.

	userList = []
	targetRole = 'Enter Role Name'
	rosterName = "Enter Roster Name"
	logger = system.util.getLogger("AlarmPipeline")
	
	try:
	    roster = system.roster.getRoster(rosterName)
	    users = roster.getUsers()
	
	    for user in users:
	        # get user's roles
	        roles = user.getRoles()
	        #logger.info("Roles for user {}: {}".format(user.get(user.Username), roles))  # Log the roles
	
	        # create userInfo object
	        userInfo = {}
	
	        # if user has the targetRole
	        if targetRole in roles:
	            # get the Contact Info of that user 
	            contactInfo = user.getContactInfo()
	            email = []
	            phone = []
	
	            # loop through list of contact info to get email list and phone number list
	            for contactType in contactInfo: 
	                if contactType.getContactType() == 'email':
	                    email.append(contactType.getValue())
	                elif contactType.getContactType() == 'sms':
	                    phone.append(contactType.getValue())
	
	# Log the phone numbers we are collecting
           		#logger.info("Phone numbers for user {}: {}".format(user.get(user.Username), phone))
	
	            # create username and contact info in the userInfo object
	            userInfo['username'] = user.get(user.Username)
	            userInfo['email'] = email
	            userInfo['sms'] = phone
	
	            # append userInfo object to userList
	            userList.append(userInfo)
	
	except Exception as e:
	    logger.error("Error occurred while calculating roster: " + str(e))
	
	return userList

I have a main Pipeline that filters the tag based on tag provider and jumps to each individual pipeline that has its own escalation setup based on what zone it comes from and sends it to the correct users.

The set property block contains:

split({fullItemPath},'/')[0,0]

and the switch simply has the property:

getProperty("tagProvider")

It might not exactly be pretty or optimized but it does work correctly.