Workflow-Help: Set Invoice Status after email is sent to customer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • snoo
    Junior Member
    • Apr 2015
    • 26

    Workflow-Help: Set Invoice Status after email is sent to customer

    Hi,

    I have troubles getting the workflow set for the following:

    After i create an invoice the status is set by default to "created".
    When i click on "E-Mail PDF" and select the template and send the mail to the accounts email, after successful delivery I want to set the status in the invoice entity to "Unpaid" via workflow.

    The Worklow looks like this:
    Trigger-Type:
    After record updated
    Conditions: Status equals "created" (and.. email is sent!?)
    Update Target Entity: Status = Unpaid.

    How can I check for a sent email for this invoice?

    Thanks in advance!
    Last edited by snoo; 08-17-2021, 09:08 AM. Reason: add tags
  • dimyy
    Active Community Member
    • Jun 2018
    • 569

    #2
    Without additional customization impossible.

    Sent email and Invoice has no any relations.


    If you want you can customize function getAttributesForEmail (/application/Espo/Modules/Sales/Services/Quote.php) and return parentType and parentId accordingly to Invoice.

    Then workflow should triggered on email.sent and check parentType status...

    Comment

    • dimyy
      Active Community Member
      • Jun 2018
      • 569

      #3
      May be control creating Attachment and check parentType = Email and relatedType = Invoice.

      Comment

      • snoo
        Junior Member
        • Apr 2015
        • 26

        #4
        Thanks for the hints.
        But i cant set up a workflow for the Attachment, only for an E-Mail. And to check if that email has an Attachment is simple. Unfortunately you cant check if that email belongs to an invoice... just to an account.. but this will get complicated.

        And i dont want to modify the code, i just want to use the tools and workflows provided.

        Comment

        • dimyy
          Active Community Member
          • Jun 2018
          • 569

          #5
          You can get attachmentsIds, then loop and check record/attribute relatedType, relatedId

          Comment

          Working...