Roll back a view or form to a previous version, force check-in, or cancel check out of a view or form
KB003346
PRODUCT
Introduction
- K2 does not recommend this procedure since the validation logic of the K2 Designer tool is ignored, and can result in unexpected behaviour. Before you make any change to a SQL database, always make a backup or a snapshot of the SQL database. Do not use this procedure in production environments.
- If you on K2 Cloud, contact the K2 Cloud support team to perform these steps for you.
You may need to roll back views or forms to a previous or deleted version, for example if a recent version of the view or form is broken to a point where it is not operational or recoverable and must be recreated.
You may also need to force a check in (or cancel a check out) of a view or form, for example if the person who has a form checked out is no longer available to check the form back in.
This article describes how to perform the following operations:
- Roll back a view or form to a previous version
- Force Check In of a view or form
- Force Cancel Check out of a view or form
Roll back a view or form to a previous version
To roll back a view or form to a previous or deleted version of the view of form, follow the steps below:
- Obtain the ID and Name of the view or form. You can find the ID and Name in different tables in the K2 database, depending on the current state of the view or form:
-
- View (checked in): Form.View table
- View (checked out): Form.View_Design table
- Form (checked in): Form.Form table
- Form (checked out): Form.Form_Design table
-
- When you save or finish a view or form, an entry is made in the Form.AuditLog table of the K2 database. To retrieve a list of the available versions of the view or form to roll back, replace the GUID in the SQL query below with the ID you obtained in step 1. SELECT * FROM RForm].rAuditLog]
where eData] Like '%GUID%'
and aXml] is not null
order by datetime desc
Use the record ID and XML fields as shown above to identify the specific view or form. The XML field contains the matching IDs (represented as a GUID) of the view or form. Open the XML to see the view or form ID and Name as shown below. - Execute the following Stored Procedure in the K2 database to revert to the specified version (you can use the same Stored Procedure to roll back both views and forms). Change the ID to the corresponding version ID as identified in the table shown above, in the ID field. Replace the Domain and Username with appropriate values. The Username must preferably be the person who created the view or form, as it will be checked out to that person when the rollback is complete: EXEC Form.mRevertToVersion'K2:{Domain}{UserName}', {ID}
Example: To roll back to the second-latest version of the view (ID=4056), the statement is:EXEC Form.mRevertToVersion'K2:denallixob', 4056The recommended approach is to begin with the one version earlier than the latest version of the view or form (for example ID 4056 in the screenshot in Step 2) to identify the version that you need. If you revert to a previous version, that version becomes the latest version of the view or form. - Use command prompt to issue an IISRESET command on the IIS server hosting the K2 Designer site, and then open the K2 Designer to access the reverted view or form.
Force Check In of a view or form
To force a Check In of a view or form, follow the steps below:
- Obtain the ID, DisplayName, and CheckedOutBy values of the view or form. You can find the ID, DisplayName and CheckedOutBy in the K2 database in one of the following tables:
- View (checked out): Form.View_Design table
- Form (checked out): Form.Form_Design table
- Execute the following SQL statement in the K2 database. Change the ID to the corresponding record ID as identified in the table shown above in the ID field. Replace the T with the correct value depending whether this is a view or a form: use 'F' if you are checking in a form and a 'V' if you are checking in a view. Replace the Domain and Username with the appropriate values - the Username must be the person who checked out the view or form. DECLARE @MyTable Form.ContextTableType;
INSERT INTO @MyTable(bID], DType])
VALUES (N'{ID}', '{T}');
EXEC XForm].raCheckInContexts] @UserID= N'K2:{Domain}{UserName}', @ContextData=@MyTable;
Example:To force a Check In of the Employees Editable List view as shown above, the statement is:DECLARE @MyTable Form.ContextTableType;
INSERT INTO @MyTable(bID], DType])
VALUES (N'70E1D06D-8806-4135-9433-FB4ABB446150', 'V');
EXEC XForm].raCheckInContexts] @UserID= N'K2:DENALLIXob', @ContextData=@MyTable; - Use command prompt to issue an IISRESET command on the IIS server hosting the K2 Designer site, and then open the K2 Designer to access the checked-in view or form.
Cancel Check out of a view or form
- If the view or form was never checked in and checked out again, using this procedure will delete the view or form from the database and not perform a Cancel Check out as expected. For example, when you use the Generate Views feature to automatically generate a view or form, it is saved to the Form.View_Design table for views and to the Form.Form_Design table for forms. If you apply the procedure mentioned below in this specific instance, it will delete the view or form. Make sure the view or form was at least checked in and out once before you run this statement.
- The recommended approach is to force Cancel Check out of a view or form one at a time so that you can verify that the action was successful before forcing Cancel Check out for the next item.
To force a Cancel Check out of a view or form, follow the steps below:
- Obtain the ID, DisplayName, and CheckedOutBy values of the view or form. You can find the ID, DisplayName and CheckedOutBy in the K2 database in one of the following tables:
- View (checked out): Form.View_Design table
- Form (checked out): Form.Form_Design table
- If you are cancelling check-out of a view, run the following statement in the K2 database. Change the ID 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 must be the person who checked out the view. EXEC XForm].raUndoViewsCheckOut] @UserID = N'K2:{Domain}{UserName}', @IDs = N'{ID}';
If you are cancelling check-out of a form, run the following statement in the K2 database. Change the ID 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 must be the person who checked out the form:EXEC XForm].raUndoFormsCheckOut] @UserID = N'K2:{Domain}{UserName}', @IDs = N'{ID}';
Example:To force a Cancel Check out of the Employees Editable List view as shown above, the statement is:EXEC XForm].raUndoViewsCheckOut] @UserID = N'K2:Denallixob', @IDs = N'70E1D06D-8806-4135-9433-FB4ABB446150'; -
Use command prompt to issue an IISRESET command on the IIS server hosting the K2 Designer site, and then open the K2 Designer to access the checked-in view or form.