The Workflow Comment and Workflow Attachment System SmartObjects added can be used in the context of a workflow to add or view comments or attachments associated with a workflow instance. As an example, an employee submits a leave Form for approval and the HR manager might want to add a comment about the leave Form, such as “This leave is considered leave without pay” so that the next approver (Manager) can see the comment and act accordingly.
The following Process Rights are required to use the Workflow Attachment and Workflow Comment SmartObjects. Because Comments and Attachments are added on a process instance level and not on a worklist item level, a user has to have process rights in order to use these SmartObjects; a user with just an active worklist item without any process rights cannot add or view Comments and Attachments. Process Rights can be managed in the K2 Workspace, K2 Process Portals, the K2 Management site in K2 for SharePoint, and when workflows are designed in the web-based workflow design tools.
Start | View | View Participate | Admin | Server | All | |
---|---|---|---|---|---|---|
Workflow Attachment | ||||||
GetList |
Deny |
Allow | Conditional Allow |
Allow |
Deny | Allow |
AddAttachment | Allow | Allow | Conditional Allow |
Allow |
Deny | Allow |
GetAttachment |
Deny |
Allow | Conditional Allow |
Allow |
Deny | Allow |
Workflow Comments | ||||||
Add Comment |
Allow |
Allow | Conditional Allow |
Allow |
Deny | Allow |
GetList |
Deny |
Allow | Conditional Allow |
Allow |
Deny | Allow |
The Workflow Attachment and Workflow Comment SmartObjects are located in the System > Workflow folder in the K2 Designer. You may need to select the show System Objects option to see the SmartObjects in the Designer.
The process instance ID of the workflow is required to work with the Workflow Attachment and Workflow Comment SmartObjects, because this is the value that ties a Comment or Attachment to a workflow instance. If you wish to use these SmartObjects in your workflow forms, the Process Instance ID needs to be mapped in the methods used to add or retrieve Comments and Attachments. If you are using K2 SmartForms, you will need to add the integration with the Comments and Attachments SmartObjects as described below. Comments and attachments SmartObjects can be used in multiple ways to ADD or DISPLAY comments and attachments, the key to the successful use is configuring the Process Instance ID that is always required
The following is an example of configuring the SmartForms and Workflow in a K2 for SharePoint Application to support adding and viewing comments in Forms associated with a workflow.
The example used is an employee that submits a Leave Form and wants to add a comment on the Form describing the type of leave they want to take such as vacation leave. For a subsequent approval task, we will display the comments added to the workflow on the approval Form and allow the approver to add additional comments. To achieve this, the Start Form contains two Views: The New Leave Application View, created in the K2 Application, contains leave information which is linked to the Leave SmartObject in the K2 Application, and the Comment Item View is an Item View of the Workflow Comment SmartObject, created in the K2 Designer. The user is able to capture comments while completing the leave information.
Adding comments when the leave request workflow is started:
The Approval Form contains three Views: The Edit Leave Application View contains leave information which is linked to a Leave SmartObject, the Comments List View is used to show a list of the previous comments for this workflow, and the Comment Item View is an Item View of the Workflow Comment SmartObject. The approver is able to add comments when submitting their decision on the leave request.
Displaying and saving comments when the leave request is approved:
Here are the high level steps to configure the Form and Workflow from the K2 Application, to save and load Comments. You can follow a similar procedure to add the Attachments integration if you wish; for this scenario we will only use the Comments SmartObject.
The first step is to create a SharePoint custom list called Leave Application and create the K2 Application from this custom list. Ensure to include all the elements in the K2 Application; Data, Forms, Workflow and Reports.
For the Workflow Start Option, select the When a SmartForm is submitted option and ensure the New Leave Application form is selected from the drop down.
Click OK to create the K2 Application elements. Drag a Placeholder onto the canvas and save the workflow. We will return later to design the workflow. Click on Close & Exit to go back to the K2 Application.
The second step is to create Views that will be used to Add and Display (List) comments. You may create the Views once and re-use them across multiple Forms and Applications, or create separate Views for each Application. You may also use the built-in Views called K2 Workflow Attachments View and K2 Workflow Comments View to display a list of Comments, if you prefer, but for this sample we will create Views to both Add and Display (List) Comments.
The New Leave Application Form will be used to start the workflow. Add the Workflow Comments Item View that you created in the previous step to the Form. We will configure this View in a later step.
Now we need to edit the Edit Leave Application Form that will be used for the approval step of the workflow.
The process instance ID of the workflow is required to work with the Workflow Attachment and Workflow Comment SmartObjects, because this is the value that “ties” a Comment or Attachment to a workflow instance. If you wish to use these SmartObjects in your workflow forms, the Process Instance ID needs to be mapped in the methods used to add or retrieve Comments and Attachments. If you are using K2 Application forms, you will need to add the integration with the Comments and Attachments SmartObjects as described below. Comments and attachments SmartObjects can be used in multiple ways to ADD or DISPLAY comments and attachments, the key to the successful use is configuring the Process Instance ID that is always required.
Follow the steps below to design the workflow:
Edit the New Leave Application Form. Configure the Start Workflow action, and set up the Output Mappings so that the Workflow ID is passed into the ProcInstId Form Parameter, as shown below.
You can now test your scenario by running the New Leave Application Form to start a new workflow instance and adding comments. You can also then open the User Task to retrieve comments and add new comments. Follow these steps:
When using K2 for SharePoint you can view the Comments and Attachments linked to a K2 Application workflow using the Report button or Reports link in the K2 for SharePoint administration pages, as shown below.
Click on an instance to view the details. Note: If no comment or attachment has been added, the section containing the Workflow comments will not be visible in the report.
For more information on viewing comments and attachments, see the Using Reports topic.
Video | Links | Learn | Support |
No videos found for this article K2 on YouTubeNo Additional links found for this article No self-learning content for this article Try some scenarios...No relevant support links available for this article |