Increment ID in invoice/contract

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • timarebel
    Member
    • Jul 2021
    • 33

    #1

    Increment ID in invoice/contract

    Hello

    I want to make an ID number where which contract has invoices and this invoices have ID incemented by 1
    how can I know the previous of each record invoice which below to that one contract.
  • eymen-elkum
    Active Community Member
    • Nov 2014
    • 481

    #2
    Hello,

    Add new int field to the parent entity and set the value using this formula script:

    Code:
    $invoiceCount = record\count('Contract', 'contractId', contractId);
    
    ifThen(entity\isNew(), $invoiceCount = $invoiceCount + 1);
    
    record\update(
        'Contract', contractId,
        invoiceCount, $invoiceCount,
    );
    Last edited by eymen-elkum; 11-18-2021, 12:39 PM.
    EspoCRM Expert since 2015
    We build custom solutions & premium extensions
    Eblasoft Technology Solutions​

    Comment

    Working...