action.skip

Enabling Automatic Finalization With Flow

← Setting Up Invoice Finalization

Your organization's business may require to finalize invoices automatically when certain conditions become true.

To this end, JustOn Billing & Invoice Management provides the specific Apex class InvoiceStatusChange. You can use this class to set up an according flow.

Info

The Apex class covers multiple use cases. To finalize invoices, make sure to pass the variable Finalize. This will finalize the involved invoices, setting their status to Open.

Modified InvoiceStatusChange behavior with JustOn 2.80

JustOn 2.80 has modified the behavior of the involved Apex class InvoiceStatusChange.

Up to version 2.79, the class – and thus, the flow – synchronously executed the cancellation and finalization. This meant that after the flow execution was finished, the finalization and cancellation were also completed. However, the finalization did not include all batch classes of the FinalizeInvoiceChain but only the BatchFinalizeInvoice class. Therefore, the flow did not execute operations like settlement, balance assignment, installment creation, PDF generation, etc.

Starting with version 2.80, the flow calls the FINALIZEINVOICE batch chain to finalize the invoices. Consequently, it executes all operations of the included Apex classes (see FinalizeInvoiceChain). The batch chain runs asynchronously – this means that after the flow execution has finished, the invoice finalization is not yet completed.

The flow still executes the cancellation synchronously, though, before starting the finalization.

Note

Depending on your use cases, the flow setup and the objects to involve will vary.

  1. Click to enter Setup, then navigate to Process Automation > Flows.
  2. Click New Flow.
  3. Select Record-Triggered Flow and click Create.
  4. Configure the Start element.

    Option Description
    Object The object whose record modifications are to change the invoice status
    Trigger The type of record change that triggers the flow
    Conditions The use case-specific trigger conditions, one or more filter criteria for evaluating certain field values
    Optimize for Actions and Related Records
  5. Click and add the following Action element.

    Option Description
    Action The Apex class to call, must be Change invoice status
    Input Values Invocable variables for the Apex class
    "Cancel", "Finalize" or "Cancel + Finalize": string value that specifies the operation to be executed, must be Finalize
    Invoice Id: specifies the invoices to be modified, usually produced via lookup relation from the original object to the related invoice, like {!$Record.ON_Invoice__r.Id}

    Specify a label and an API name as required.

  6. Click Save.

    Specify a label and an API name as required.

  7. Click Activate.

    When the defined conditions are met, JustOn triggers the intended operation.

    For help about creating flows, see Flows in the Salesforce Help.