Skip to main content
Skip table of contents

Reading Legacy Event Data

The way event action and trigger types are implemented and managed has been changed from the way it was done in the legacy API.  This means that actions and triggers created using the legacy API will throw exceptions or be unreadable when using the default action and trigger data processing logic.  To remedy this, and restore your plugin's ability to read legacy data, override the AbstractActionType.ConvertLegacyData Method or AbstractTriggerType.ConvertLegacyData Method respectively.  

This page covers the process for enabling the support of legacy HS3 data in HS4 action and trigger types.

On this page:



Because legacy data will not be re-saved and upgraded to the modern format until the corresponding action or trigger is edited and then saved by the user it is important to include code to handle executing the action or evaluating the trigger when the configuration data is still in the legacy format.



Summary

Whenever an action or trigger instance is initialized, the configuration data, serialized and encoded as a byte array, is deserialized into the JUI page used to store configuration options and presented to the user.  When the configuration data is still in the legacy format, this will cause an exception during deserialization and the configuration will be defaulted to a blank JUI page.  To modify this process so legacy data can be properly read from the data the ConvertLegacyData method needs to be overridden in your implementation of the AbstractActionType Class or AbstractTriggerType Class.


Override the ConvertLegacyData method

Override this method and include the necessary code to deserialize your custom legacy data.  If you used the data serialization methods defined in the legacy API, you can take advantage of the TrigActInfo.DeserializeLegacyData(TOutObject) Method to deserialize your legacy data. For example:

C# Example

C#
protected override byte[] ConvertLegacyData(byte[] inData) {
	
	MyLegacyEventActionDataClass legacyAction;
	if (inData != null && inData.Length > 0) {
		try {
			//attempt to deserialize the byte array to your custom class
			legacyAction = TrigActInfo.DeserializeLegacyData<MyLegacyEventActionDataClass>(inData);
		}
		catch (Exception ex) {
			//if there was a problem - set the legacy data object to null
			legacyAction = null;
		}
	}
	
	if (legacyAction == null) {
		return new byte[0];
	}
	
	//Replace the following line with your own code to upgrade your legacy data to modern config page
	ConfigPage = ConvertLegacyDataToConfigPage(legacyAction);
	
	//return the Data property to automatically convert the ConfigPage to a byte array for later storage
	return Data;
}

VB.NET Example

VB
Protected Overrides Function ConvertLegacyData(inData As Byte()) As Byte()
	
	Dim legacyAction As MyLegacyEventActionDataClass
	If inData IsNot Nothing AndAlso inData.Length > 0 Then
		Try
			'attempt to deserialize the byte array to your custom class
			legacyAction = TrigActInfo.DeserializeLegacyData(Of MyLegacyEventActionDataClass)(inData)

		Catch ex As Exception
			'if there was a problem - set the legacy data object to null
			legacyAction = Nothing
		End Try
	End If
	
	If legacyAction Is Nothing
		Return New Byte() {}
	End If
	
	'Replace the following line with your own code to upgrade your legacy data to modern config page
	ConfigPage = ConvertLegacyDataToConfigPage(legacyAction)
	
	'return the Data property to automatically convert the ConfigPage to a byte array for later storage
	Return Data
End Function
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.