Answer by Francis Martens (Exalate) on 25 March 2021
Is there a functional difference between these two calls?
Yes there is a big functional difference.
issue.setStatus will try to find the shortest path between the current issue status and the target status, and use that route to perform one or more transitions. The workflowHelper.transition will just perform the requested transition.
2. Should I prefer one over the other or is there a 3rd way?
Depends on the use case. .transition is to be used when the choosen path is not the correct one. For instance if there are 2 transitions between status A and B, issue.setStatus might choose the wrong transition.
3. Do either or both run the transition (and post functions) between current state and “Completed” state?
Yes. Note that .transition takes the transitionName, while setStatus takes the target status.
4. Out of interest if there is no transition between current state and “Completed” state will this sync fail
The call is ignored, the sync will not fail
5. Does the change in JIRA state cause the issue to re-sync back to ADO?
No. Changes performed in the context of a sync transaction, will not trigger a new transaction