How to generate contract and allowance codes based on firm code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • trkkrt
    Junior Member
    • Aug 2025
    • 2

    #1

    How to generate contract and allowance codes based on firm code

    Hi everyone,

    I have three main entities: Firms, Contracts, and Allowances.
    • Firms: I have created a firmCode using a formula that takes the initials of each word in the firm name.
      Example:
      Firm Name: Apples and Bananas Inc. → Firm Code: AABI
    • Contracts: Linked to Firms. I want to generate a contractCode based on the firmCode, in a sequential manner per firm:
      Example:
      • First contract for this firm → AABI-1
      • Second contract → AABI-2
    • Allowances: Linked to Contracts. I want to generate an allowanceCode based on the contractCode and the allowance’s sequential number per contract:
      Example:
      • First allowance from second contract → AABI-2-1

    I have successfully created the firmCode. However, I am struggling to create the contractCode and allowanceCode formulas.

    Could someone guide me on how to implement these formulas in EspoCRM so that the codes are generated automatically and sequentially for each firm and contract?

    Thanks in advance!
  • heint
    Junior Member
    • Jun 2025
    • 21

    #2
    Greetings, trkkrt,

    Pretty interesting question, but please provide us with some more details about how these entities are connecting with each other (in which way Contracts and Allowances​ are being created and which fields they are sharing and where the {entity}Code is storing).

    If it's possible, please send an example screenshot of a Contracts​ entity.

    Comment

    • trkkrt
      Junior Member
      • Aug 2025
      • 2

      #3
      Thank you for your response. Let me explain in more detail:
      • Firms → Contracts: One-to-Many (each Firm can have many Contracts, each Contract belongs to one Firm).
      • Contracts → Allowances: One-to-Many (each Contract can have many Allowances, each Allowance belongs to one Contract).

      Currently:
      • While creating a Contract, the Firm name is chosen from the list of Firms and used as the Contract name. However, this can cause confusion because there can be multiple Contracts for the same Firm.
      • While creating an Allowance, it is initially named as “Allowance No: 1”, for example, and there is a field named contract that links it to a Contract. Again, this can be confusing when there are multiple Contracts for the same Firm.

      This is why we want to create entity codes (firmCode, contractCode, allowanceCode) that are generated relatively to their parent entities, so each record has a unique and meaningful code.

      I will be uploading a screenshot shortly to illustrate this.

      Comment

      Working...