Skip to main content
 

I've seen few K2ers asking how to refresh the Inbox when a task has been actioned via a SmartForm in K2 Five/Cloud Workspace.

 

 

 

Current behaviour:

 

 

 

If you noticed that whenever you action a task in the workspace, you will have to manually refresh the Inbox in order for the task to disappear. 

 

 

 

If the end user clicks on the actioned task again, an expected error will appear as the task has already been actioned by the user: 

 

 

 

15349i0FD7E737E954EB61.jpg

 

Solution - K2 Five:

 

 

 

In K2 Five it is not complicated to implement, you can trigger the refresh function using JavaScript.

 

 

 

14057iDCBAFB756682026D.png

 

 

 

The script will be executed after the button click that actions your task

 

 

 

Implementation:

 

 

 

Script

 

 

 
<script>window.top.parent.$("lid$='_refreshInput']").click();</script>
 

 

 

1- Add a data label control to your task form and make sure Literal property is checked and Prevent XSS is unchecked  

 

2- Add two transfer data action after the Worklist item action as shown below

 

 

 

15886i5E33E459A06BBCF6.png

 

 

 

3- Clear the data label in the first transfer then transfer the script in the second one

 

 

 

Solution - K2 Cloud:

 

 

 

The problem in K2 Cloud is that the task form is displayed within the workspace using different URL than the parent page (Workspace) and here the script will not work because of the security mechanism Same-origin policy .

 

 

 

There are two URLs configured for K2 Cloud 

 

1- Vanity 

 

2- KUID

 

 

 

If you use the environment library to configure your user tasks URL in the Workflow or select the from by using the browse option then the IFrame source will be https:// KUID].onk2.com/runtime/runtime/form/uFormName]..

 

and this will not be the same origin as the parent page i.e. https://VanityExample.onK2.com/Workspace

 

 

 

In this case, don't use the environment library fields (SmartForms Runtime SSL) to construct custom URLs or the SmartForms option for tasks. 

 

If you have more than one Cloud Instance, I would recommend storing your environments URLs in a SmartBox to avoid using static URL in your user tasks. then you can load the correct URL from the SmartBox and construct custom URL for the Workflow tasks 

 

 

 

Example:

 

 

 

Environment URLs stored like this 

 

16606i23277306FA968C65.jpg

 

Task Configuration:

 

 

 

13792i1CF32F3630B77F17.png

 

 

 

Filter the results as below:

 

 

 

14056i38B946060EDE2E71.png

 

 

 

I am loading the Vanity URL from the SmartBox and filtering the results by the server URL which is the same as the workspace URL that is stored in the environment fields 

 

13976i782A9494A6126435.png

 

 

 

Now you can implement the same steps mentioned above in K2 Five Solution to trigger the refresh function successfully.

 

 

 

HTH

Thanks for sharing this mate. Very helpful.


Reply