How to implement a manual entry change log using Memory Document Tags

We are looking into creating a developers change log (manual entry) within Ignition. The idea being that a team member would/could add any entry to that log when they change something and (if maintained) that could be used by the development team to quickly understand the history of recent changes.

I expect the typical implementation for this type of data might be to to utilize an external SQL database. However that would not be preserved with gateway backups.

I am exploring whether similar results could be reasonably achieved using a 'Memory Tag' (Tag Object type) and either 'Dataset' or 'Document' (JSON Document) as the Tag Data Type... for the primary reason that those would be captured in a gateway backup.

Initially we started looking at the 'Dataset' tag data type, but understanding that datasets are immutable we realized the following downsides.

  • Any log entry/edit would mean a rewrite of the entire dataset and would/could overwrite concurrent entries/edits by other team members.
  • As the change log grows large rewriting the entire dataset on any update seems like unnecessary overhead.

Alternatively we started investigating the use of the 'Document' tag data type but that seems like it may potentially suffer the same downsides as there does not seem to be a way to obtain an object reference (pointer) using scripting that would allow us to modify the document data in-place.

Questions:

  1. Is there any build-in feature or module that provides manual entry change log functionality that I should consider instead of any of the approaches above?

  2. Is there a way to modify a document tag in-place, instead of copy, modify, replace. Specifically a way to append to an array in the document tag.

  3. Are there other/better approaches that I should consider?

I was successful in using a bidirectional binding on the data property of a Perspective table, bound to an array member of a memory-document tag. Then when using scripting to append to the bound array/list on the data property of the table the change propagates to the bound memory-document tag.
However I suspect in this case the bound array(list) is being replaced rather than updated in place, which has the same downside as using a memory-document tag.

I took it further and attempted to use scripting to perform an in-place update of the document tag but it does not appear as though references to actual tags are returned by the system.tag.readBlocking() function (it was a long shot).

def runAction(self, event):

	country = self.getSibling("TextField - Country").props.text
	city = self.getSibling("TextField - City").props.text
	population = self.getSibling("NumericEntryField - Population").props.value

	if len(country)>0 and len(city)>0 and population is not None: 
		row = {
			 "country": country
			,"city": city
			,"population": population
		}

		path = ["[default]_Test/Tyler/Demo4Kosta/DocumentTag"]
		qualifiedValues= system.tag.readBlocking(path)
		value = qualifiedValues[0] 

		array = value.value['data2']

		import com.inductiveautomation.ignition.common
		import com.inductiveautomation.ignition.common.document.DocumentElement

		jsonElement = com.inductiveautomation.ignition.common.TypeUtilities().pyToGson(row)
		documentElement = com.inductiveautomation.ignition.common.document.DocumentElement.fromJson(z)
		array.append(documentElement)

I would not try to do this with tags. They're the wrong abstraction.

Personally, I would probably do this with a SQLite connection in a particular location (e.g. in the data directory) where I know it will be collected in a gateway backup. You can use a relative path to make it 'safe' to restore your gwbk across different OSes: Connecting to SQLite - Ignition User Manual 8.1 - Ignition Documentation

And then your CRUD operations for change logs become simple DB operations using existing Ignition tools.

1 Like

Does everything under the data directory get collected in a gateway backup. I only ask for confirmation because it is not explicitly listed in the manual.
https://docs.inductiveautomation.com/display/DOC81/Gateway+Backup+and+Restore#GatewayBackupandRestore-ContentsofaGatewayBackup

No, but anything with an extension of .idb is.

Recent troubleshooting shows that our SQLite database file under the data directory is not being included in a gateway backup (at least it is not being restored with the backup). Has there been a change to this functionality from what you stated in Dec 2022?

I understand the gateway backup might/must purposefully exclude random files. However, I'm still interested if there is means to have it include some custom files (like a little SQLite changelog database) by placing it in the right folder or something like that.