When you develop an application with K2 smartforms often some of the functionality you expose to the users are role dependent.
The Administration tab for instance should only be viewable by users in the Administration role. To test the functionality you then need to login as the specific user. This is quite simply achieved by executing the runas command from your command prompt:
K2 Automated Testing Software
BenchQA allows full test automation of K2, including fully automated K2 SmartForms and K2 Workflow testing. It promotes test driven development for K2 and ensures continued quality assurance for K2 solutions. Easily apply changes to test cases to accommodate changes to K2 apps and ensure all apps are regression tested to avoid defects and assure continuous quality.
runas /user:domainusername “c:Program FilesInternet Exploreriexplore.exe”
Usually while you develop your changes are immediately visible at the runtime URL of your form, after you have saved your changes . But when you login as another user there is a little gotcha that has caught me out multiple times. You need to remember to check-in your changes, otherwise the changes will not reflect.
Another issue that often arises is when you need to force a check-in on a forms and views that an employee who is on leave/sick/has left has checked-out. To do this you will need to execute some queries against the K2 database. You can use the following queries to retrieve the ID’s of the forms/views that has been checked out:
USE K2
–For checked out views
SELECT ID, DisplayName, CheckedOutBy
FROM Form.View_Design
WHERE CheckedOutBy = ‘K2:DenallixUsername’
–For checked out forms
SELECT ID, DisplayName, CheckedOutBy
FROM Form.Form_Design
WHERE CheckedOutBy = ‘K2:DenallixUsername’
Now that you have the ID’s of the views and forms that has been checked out you will need to execute the [Form].[aCheckInContexts] stored procedure in the K2 database. The Pprocedure has two parameters, the first being the UserID (domainusername) and the second being a table variable consisting of two columns. The first column is the ID of the form/view that needs to be checked in and the second is the Type – ‘F’ for forms or ‘V’ for views. The code belowe shows how this can be achieved:
DECLARE @MyTable Form.ContextTableType
INSERT INTO @MyTable([ID], [Type])
VALUES (N’97CD2824-D36D-46A7-97AF-BA0F2DFF06CD’, ‘F’)
EXEC [Form].[aCheckInContexts] @UserID= N’K2:DENALLIXUsername’, @ContextData=@MyTable