Skip to content
Browse topics

Validation rules and actions after saving

Add your company's own rules that stop a document, payment or record from being saved, and automate what must happen after it is saved, like SAP Business One's TransactionNotification and PostTransactionNotice.

Updated November 7, 2026

On this page

Nori already has its own rules (credit, minimum price, maximum discount, stock…). Here you add your company's, without programming. There are two kinds, with the same difference as in SAP Business One:

  • Validation rules: they check before saving and can stop it. They are SAP's SBO_SP_TransactionNotification.
  • Actions after saving: they run once it is saved and cannot stop it. They are for reacting: notifying, updating something else, sending data to another system. They are SAP's SBO_SP_PostTransactionNotice.

The rule of thumb: what must prevent something goes in a validation rule; what must happen as a consequence goes in an action after saving. A validation set up as an action after saving seems to do nothing, because when it runs the document already exists.

Create a validation rule

They are set up by whoever has the validation rules permission. The Administrator has it.

  1. Go to Administration › Customization › Validation rules and press New.
  2. In Applies to choose what it checks: a document type, Every document, incoming or outgoing payments, or a catalog (partners, items…).
  3. Check when: On add, On update, On cancel or On close.
  4. Write the Query that looks for the problem.
  5. Write the Message the user will see and save.

The query

It is a SELECT that looks for the problem: if it returns a row, Nori does not save and shows the message. If it returns nothing, everything goes on.

It reads these values:

  • :id: the document, payment or record.
  • :action: add, update, cancel or close.
  • :subject: what it applies to (documents.invoices, payments.incoming, catalogs.items…).
  • :user_id: who is saving it.

It sees the record as it will be left, with its lines. If the rule stops it, everything is undone: no document, no stock movement, no journal entry.

If the query brings a message column, that is the message; otherwise the rule's Message is used.

Examples

Invoices without the customer's purchase order:

SELECT 'Enter the customer purchase order' AS message
FROM documents
WHERE id = :id AND customer_po IS NULL

Orders with more than 100 pieces in a line:

SELECT 'Line ' || line_number || ' is over 100 pieces' AS message
FROM document_lines
WHERE document_id = :id AND quantity > 100

New items without a group:

SELECT 1 FROM items WHERE id = :id AND item_group_id IS NULL

When each one checks

  • On add: when a new document is posted (a draft is not checked until it is posted), a payment is recorded or a record is created.
  • On update: when an open or posted document, or a catalog record, changes.
  • On cancel: before the cancellation is requested from the SAT, with the document or payment as it is.
  • On close: when a quotation, order or request is closed by hand.

Rules run wherever things are saved: screens, point of sale, mobile app, API and online stores. They do not run on what comes down from the ERP or in the migration from desktop.

A rule with an error in its query also stops the save and says what the error is. Deactivate it while you fix it.

Actions after saving

What must happen after saving is done with a script or an API webhook. When choosing When it runs › When something happens in a script you can pick, besides the usual events:

  • A document was created, posted or cancelled.
  • A payment was received or cancelled.
  • A CFDI was stamped or cancelled.
  • A home delivery changed.
  • A customer was created or changed.
  • An item or its stock changed.

The script receives the record's id and data. It runs in the background, after saving: if it fails, what was saved does not change, and the error stays in its runs.

Related articles

Can't find something?

Tell us what you need to do and we'll get back to you. If you're already a customer, include your company's name.

Contact us