How to roll back to a deleted or previous version of a View or a Form
KB001311
PRODUCT
Introduction
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.
Implementation
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.
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:
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.
Execute the following statement on the Form.AuditLog table of the K2HostServer SQL database:
- Change the ID above to the corresponding record ID as identified in the table shown above in the ID field.
- 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.
Example
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:
Example of Stored Procedure
GO
DECLARE @return_value int
EXEC @return_value = Form].[mRevertToVersion]
@UserID = N'K2:DENALLIXBernard',
@AuditLogID = 54
SELECT 'Return Value' = @return_value
GO