Create 'Purchase Order Reference' in Subscription and use it in Invoice

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SailReal
    Member
    • Jun 2025
    • 37

    #1

    Create 'Purchase Order Reference' in Subscription and use it in Invoice

    Hey all,

    What is the best way to create a 'Purchase Order Reference' field in the Subscription entity and apply it to the 'Purchase Order Reference' field in an Invoice? The idea is to have logic like this: if a 'Purchase Order Reference' is set in the Subscription, use that in the Invoice; if one is set in the Invoice, use that; if none is set, use none when creating an Invoice.

    The idea behind this is as follows: Some of our customers require a 'Purchase Order Reference' on the Invoice. For some of these customers, this reference does not change during the subscription, so it would save us a lot of time if we could set it in the Subscription and use it in the Invoice.

    What is the easiest way to achieve this without causing any issues or breaking behavior e.g. while creating auto invoices etc?
  • yuri
    EspoCRM product developer
    • Mar 2014
    • 9794

    #2
    Hi,

    When an invoice is created from a subscription, it is related to the corresponding Subscription Period record in the 'subscriptionPeriods' link-multiple field. If you store PO Reference in the subscription's custom field, you can retrieve it through the 'subscriptionPeriods' link in a before-save script.

    Comment


    • SailReal
      SailReal commented
      Editing a comment
      Thanks for the fast response. Will try to implement it like that. Regaring "Maybe we'll consider implementing this logic in future.", if it's going to be implemented, it won't be any time soon, right?

    • yuri
      yuri commented
      Editing a comment
      We are currently focused on different things, so it may take some time, if we decide to add this feature.

    • SailReal
      SailReal commented
      Editing a comment
      Implemented it and works awesome.

      No problem, when Espo does support it someday, we can just migrate the values of 'cPurchaseOrderReference' to 'purchaseOrderReference' and remove our before-save script again. Thanks again for the hint.
Working...