How to roll back to a deleted or previous version of a View or a Form

  • 15 February 2022
  • 0 replies

Badge +3

How to roll back to a deleted or previous version of a View or a Form


K2 smartforms
K2 smartforms 1.0
This article has been archived, and/or refers to legacy products, components or features. The content in this article is offered "as is" and will no longer be updated. Archived content is provided for reference purposes only. This content does not infer that the product, component or feature is supported, or that the product, component or feature will continue to function as described herein.





This Knowledge Base article describes how to roll back to a previous version of a View or a Form.

  • This procedure is not recommended as the validation logic of the designers will be lost and could result in unexpected behavior. Also note that this procedure should NOT be used in production environments.
  • The latest How To topics are available in the K2 Five User Guide or the K2 Cloud User Guide’s How to section.
This article requires that you directly modify the K2 database. If done improperly or on the wrong version of K2, modification of the K2 database definition, permissions or content may result in system instability or system failure. It is highly recommended to make backups of the K2 database prior to performing any modification. (If available, K2 recommends that you also test database modifications in a non-production environment first.) If you have any concerns, please contact K2 Support before proceeding.






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);

The Form.View table with view checked in

and in the Form.View_Design table (if the View is checked out).

The Form.View table with view 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 Form.AuditLog table

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

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 orange and the View indicated in Green above. For example record ID field value = 54 in the image above 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.

Identifing the View ID

Execute the following statement on the Form.AuditLog table of the K2HostServer SQL database:

EXEC Form.mRevertToVersion'K2:{Domain}{UserName}', {ID}
  1. Change the ID above to the corresponding record ID as identified in the table shown above in the ID field.
  2. Replace the Domain and Username with the correct values. The Username should preferably be the person who created the View/Form as it will be checked out to that person when the rollback is complete.


Let’s say that the version of the Form deployed in record ID=55 above 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 Form (ID=54), the statement would be:

EXEC Form.mRevertToVersion'K2:DENALLIXBernard', 54

Example of Stored Procedure

USE [K2]

DECLARE @return_value int

EXEC @return_value = Form].[mRevertToVersion]
@UserID = N'K2:DENALLIXBernard',
@AuditLogID = 54

SELECT 'Return Value' = @return_value

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.


0 replies

Be the first to reply!