Workflow guidelines
In practice, Guidewire recommends that you keep the following guidelines in mind as you work with workflows:
- If you invoke a workflow
TRIGGER, do so synchronously if you need to make immediate use (in code) of the results of that trigger. For this reason, the PolicyCenter rendering framework typically always invokes the trigger synchronously. But notice that you only get immediate results from anAutoStep Workflow Stepthat might have executed. If the workflow encounters aManualStep Workflow Stepor anActivityStep Workflow Step, it immediately goes into the background. - If you complete an activity, it does not synchronously (meaning immediately) advance the workflow. Instead, a background process checks for workflows whose activities are complete and which are therefore ready to move forward. Guidewire provides this behavior, as otherwise, if an error occurs, the user who completes the activity sees the error, which is possibly confusing for that user.
- If you invoke a workflow
TRIGGERfrom code that does not necessarily care whether there was a failure in the workflow, you need to invoke theTRIGGERasynchronously. (You do this by setting thesynchronousvalue in the workflow method tofalse.) That way, the workflow advances in the background and any errors it encounters force the workflow into theErrorstate. The exception does not affect the caller code. However, the calling code creates an exception if it tries to invoke an unavailable or non-existent workflowTRIGGER. Messaging plugins, in particular, need to always invoke triggers asynchronously.
