A recent project needed several task management workflows, which meant exploring the pros and cons of each option in SharePoint designer.
Using the “Start Task Process” has the benefit of the workflow being aware of the outcome and “waiting” until the task process is complete. this means you can easily act upon the result, approve or reject, later on.
However you cannot easily get to the other task fields, or the ID, if you need to add extra data. The “Start Task Process” only returns the outcome as a variable but the biggest issue is that the workflow does not progress after this task has been created, it waits, so leaves no chance to update it before completion.
The workflow needs to perform some actions in parallel, sort of, and a “HTTP Web Service Action”.
The web service can get the ID of the latest Task by using the following URL
[%Workflow Context:Current Site URL%] /sites/mySite/_api/web/lists/getbytitle('tasks')/items?$top=1&$orderby=Id%20desc
Using this URL in a “Call HTTP web service” to return “ResponseContent”
The next action is get item from dictionary
Get d/results(0) from Variable: ResponseContent (Output to Variable: ResponseContent )
Following with this
Get Id from Variable: ResponseContent (Output to Variable: TaskId )
This can only work if the workflow runs in a parallel block but with a tweak to run slightly after – this ensures the task item is definitely there.
Setting up the call web service can be done in this way
Do the web service setup steps as normal then add a parallel block
Add and configure start task process into it
The following actions will run in parallel: Start a task process with Variable: Region (Task outcome to Variable: Outcome1 )
Then add an If block
If Current Item:ID is greater than 0
This allows a run of actions sequentially (but still in parallel to the task). Without this the next steps would all trigger at the same time.
Add a pause before continuing just to ensure the task IS created
Pause for 0 days, 0 hours, 1 minutes
Then call the web service
Call [URL]... HTTP web service with request (ResponseContent to Variable: ResponseContent |ResponseHeaders to responseHeaders |ResponseStatusCode to Variable: responseCode1 )
Manage the results
Get d/results(0) from Variable: ResponseContent (Output to Variable: ResponseContent ) Get Id from Variable: ResponseContent (Output to Variable: TaskId )
You can then update an item in a list using the newly found TaskId
After that you can continue outside of the parallel block and wait for the task to be Completed.