It is important to note that this procedure is not recommended as the validation logic of the designers will be lost and could result in unexpected behavior. Before making any change to a SQL database ALWAYS make a backup or a snapshot of the SQL database. Also note that this procedure should NOT be used in production environments.
Audience | Required Knowledge |
---|---|
|
|
Views or Forms can be rolled back to a previous version or deleted version of the View or Form.
The ID and Name of a View can be found in the Form.View table (if the View is checked in);
and in the Form.View_Design table (if the View is checked out).
Similarly, the ID and Name of a Form can be found in the Form.Form table (if the Form is checked in) and in the Form.Form_Design table (if the Form is checked out).
When a View or Form is successfully deployed (when it is Saved or the wizard is Finished) an entry is made in the Form.AuditLog table of the K2HostServer SQL database as shown below.
The specific View or Form can be identified by using the record ID and XML fields. The XML field contains the matching IDs (represented as a GUID) of the Form indicated in purple and the View indicated in green below.
For example record ID field value = 5436 in the image below and related ID (represented as a GUID) in the XML field.
Open the XML to see the View or Form ID and Name as shown below.
Filter out the information and get the versions that relate to ONLY what you need in the Audit log table by using the following SQL query:
SELECT * FROM [K2HostServer].[Form].[AuditLog]
Where cast(Xml as nvarchar(Max)) Like '%GUID%'
order by datetime desc
Execute the following statement on the Form.AuditLog table of the K2 SQL database:
EXEC Form.mRevertToVersion'K2:{Domain}\{UserName}', {ID}
Let’s say that the version of the View deployed in record ID=5444 below broke the designer or runtime to a point where it is not recoverable and has to be recreated.
To roll back to the previous version of that View (ID=5436), the statement would be:
EXEC Form.mRevertToVersion'K2:K2WORKFLOW\BernardB', 5436
Example of Stored Procedure
USE [K2]
GO
DECLARE @return_value int
EXEC @return_value = [Form].[mRevertToVersion]
@UserID = N'K2:K2WORKFLOW\BernardB',
@AuditLogID = 5436
SELECT 'Return Value' = @return_value
GO
The SQL command can be used for both Views and Forms. The mRevertToVersion stored procedure in the audit log will determine whether it's a View or Form from the [Form].[AuditLog] table record and redeploy the View or Form as that version. The @AuditLogID is linked to a specific View or Form. The @AuditLogID should be treated with caution as this will determine which View or Form will be reverted.
Video | Links | Learn | Support |
No videos found for this article K2 on YouTube
No Additional links found for this article
No self-learning content for this article Try some scenarios...
No relevant support links available for this article
|