To Save Changes Before an Action Is Performed

In workflow code, you specify that changes should be persisted to the database after an action is invoked but before the action is actually performed. You may need this capability, for example. to save user input before a dialog box is displayed.

To specify that data should be persisted before an action is performed, in the action definition, you call the WithPersistOptions method and provide the ActionPersistOptions.PersistBeforeAction parameter.

By default, no changes are persisted to the database before an action is performed.

The following code shows an example of an action definition with the WithPersistOptions method. This action opens the formClose dialog box and saves changes to the database before the dialog box is displayed.

var actionClose = context.ActionDefinitions.CreateNew(_actionClose, a => a​
  .WithForm(formClose)​
  .WithPersistOptions(ActionPersistOptions.PersistBeforeAction)​);