Integration Toolkit Solutions Wiki

Accepting a single tagPath or list of tagPaths into tags (for backward compatibility)

I recently needed to add support for reading a list of tagPaths rather than just a single tagPath in a template, but needed to keep backwards compatibility, and compatibility for existing view template instances that don't have the new list param at all.

This expression essentially creates a single list of tagPaths by combining a single tagPath string and the new list of tagPaths into one list and then subscribing to their values with tags.

For this template, the tagPaths are actually paths to a UDT instance and I needed to read a specific tag from them, so in the expression I also append the relative path to the tag as well.

Expression
tags(
	forEach(
		asPairs(
			if(
				{view.params.decorations.alarms.alarmSummaryAreaPath} != '',
				asList({view.params.decorations.alarms.alarmSummaryAreaPath}),
				asList()
			), // if the param is '', present as an empty list, otherwise wrap it into a list
			coalesce(
				{view.params.decorations.alarms.alarmSummaryAreaPaths},
				asList()
			) // if the param is Null, present as an empty list
		),
		it() + '/Alarm Summary/Status'
	)
)
Example of input values

alarmSummaryAreaPath:
"[tagProv]Path/To/Folder"

alarmsummaryAreaPaths:

[
   "[tagProv]Path/To/Other Folder",
   "[tagProv]Path/To/Other Other Folder"
]

The expression will subscribe to these tags:

[
   "[tagProv]Path/To/Folder/Alarm Summary/Status",
   "[tagProv]Path/To/Other Folder/Alarm Summary/Status",
   "[tagProv]Path/To/Other Other Folder/Alarm Summary/Status"
]
2 Likes