HowTo: Completing a Workitem From the Application Associated with Another Activity

Unofficial Content
This documentation is valid for:

Suppose that, from an application associated with an A activity, you want to complete the workitem associated with a B activity. In this case, the workflow context workitem is the one corresponding to the A activity, and not to the B activity. Consequently, you must iterate in the collection of workitems associated with the process instance, in order to search for the one corresponding to B Activity. One of the processes to do this is shown below:

&workitems = &wfprocessinstance.Workitems
For &i = 1 to &workitems.Count
	&workitem = &workitems.Item(&i)
	&activity = &workitem.Activity
	If &activity.Name = 'B'
		&workitem.Complete()
		commit
	Endif
Endfor

Where the variable data are:

&wfprocessInstance 	– WorkflowProcessInstance
&workitems 		– WorkflowWorkitem (collection property = yes)
&activity		– WorkflowActivity
&i			– Numeric(4)