How to abort the creation of a record

Is there a way to build a workflow that will allow entry of record data into its input page, but allow termination of the workflow before the record is committed (e.g. if the input data failed required checks)?

Assuming the record field is not mandatory, you are not using any field validations, and you want to execute some business logic that says before a record is created or updated, it must pass your logic tests, I would use a beforeCreate and a beforeUpdate workflow trigger, use a function and/or expression to execute your logic, and if the logic test is not passed (Gateway), use the Error step in the workflow to prevent the record update or record creation.

1 Like

There’s a function called Compose Record Maker, which apparently lets you define a Compose Record without saving it. Would this be useful for this case?

If so, how do you commit the Compose record once you’re satisfied with the inputs?

We use Compose Record Maker in the following example circumstance ….

Let’s say you have a Notes module, where a user can make a note or a comment and attach it to a Contact record to reflect a customer conversation.

On the Contact record, we would:

  1. use an onManual workflow trigger,
  2. use a prompt to capture the customer conversation text
  3. then we would insert Compose Record Maker function to define which module we want to create the new record in (Notes module),
  4. then we use an expression to set the values in the new Note record.
  5. then we would use the Compose Record Create function to take the draft Note record and create the note as a new record,
  6. end the workflow.

I think there is a good example of this pattern in the demo Corteza Ticketing namespace.

Think of the Compose Record Maker function as creating an empty draft of a new record — it has no field values — you then have to fill in the values.

Hope this helps.

Mark

Mark,

I tried to use the error step to prevent record update, but the record still saves and, when I tested it, the error step itself threw an error: " Step #, execution failed." Any suggestions?

Thats what the error step does. It throws an error with the message you provide.

Is the record still supposed to save? The documentation suggests that it should not save, but a test workflow demonstrates otherwise.

With this workflow, I would expect the record to not be created, but it is. Am I doing something wrong?

I found it. The user prompt can’t be used with the error handlers and still abort the record.

1 Like

Indeed, deferred workflows cannot be aborted like that.

1 Like