Symptoms
Activity Instance Destination Issue
Diagnoses
I am trying to retrieve the Activity Instance Destination ID from the Activity Instance Destination smartobject in order to create a serial number. To do this I basically search by Process Instance ID with the List method and select that it should only return the last item and return the Activity Instance Destination ID. However somehow it fails to retrieve the Activity Instance Destination ID and it returns 0.
When I try to find the Activity Instance Destination ID via the SmartObjects - Services - Test then I get the result that I need. In the tester I use the exact same Process Instance ID as input. Note that retrying the process does not resolve the issue even though I can see the Activity Instance Destination ID in the tester.
I even tried a simple process which basically sends me a notification with the Activity Instance Destination ID and I even typed in the Process Instance ID as a static value. However this simple test process also keeps returning 0 instead of the actual ID.
Resolution
The thing is that the execution context between The SmartObject Tester Tool and the workflow is a lot different.
The Tester Tool will execute as the user that opened the tool. If you are curious to see this, look at the SmartObject logs to see what account is being used.
The workflow gets executed using the K2ServiceAccount - if you look at the properties of an Event you will notice that the Run As is set to the ServiceAccount.
The data that the client wants to return is process data.
The 2 options available:
* On the SmartObject Event - set the Run As as an account that has (at least) view rights on the process
* Or give the K2 Service Account at least View Rights on the process