Problem:
I have a workflow setup where logged-in users submit a form, choose an assignee, then the assignee fills in a couple of fields in the same form, and saves. The workflow is complete at that point. I have a GravityView datatable that is accessible by the assignee that shows the submissions that are received by him. However, once the workflow is complete, those listings disappear from the list.
Solution:
Since Gravity Flow releases the assignee as soon the workflow step is complete, therefore entries will not show up for this assignee in Gravity View once the workfkow is complete or the entry has been assigned to a different assignee. To overcome this problem we need to create a hidden field and store the selected user (assignee) in that hidden field.
The hidden field will then be used to filter entries for the logged in user even if the workfklow has ended.
Note : You will need following plugins and extensions to complete the steps :
- Gravity Forms.
- Gravity Flow
- Gravity View.
- GravityView – Advanced Filter Extension
Let’s get started:
1. Setup the Form
Create three fields in the form :
a. Text field (No particualr reason for this field, just to have some information for assignee)
b. A User field (This will used by the submitter to select the assignee)
c. Another Text field or hidden field. This field will be used to store the user id selected in the ‘User’ field.
2. Add the merge tag of the User field to the hidden field as shown in the screenshot below.
Note : In this case the field id of the User field is 2, therefore merge tag would be {:2}
3. This script will be needed to copy the selected value in from the User field to the hidden text field on form submission.
4. Create a view with all the required fields. In this case we have selected all the fields.
5. Under Advanced filter you can now set the value of the hidden field to {user:ID} .
This will ensure only entries assigned to the user, selected using the User fields that match with the logged in user are shown in the view.