Workflow to copy Contacts to Document

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rouhu
    Member
    • Sep 2020
    • 39

    Workflow to copy Contacts to Document

    Hello,

    System setup:
    - EspoCRM version 8.1.0, B2C mode
    - PHP version 8.1.0
    - Logs shows no messages.

    Issue with workflow (test 2):
    - CPU goes to 100% and eventual timeout error
    - However, the workflow worked otherwise

    Steps to reproduce:
    - Create custom entity 'Suppliers' with one-to-many relationship with documents and one-to-many relationship with Contacts
    - Create workflow to copy Contacts from Suppliers to Document contacts when new document is created for the supplier, so that document is visible for Supplier in Portal

    Workflow test 1 for Document after record created (does not work and contactsIds is missing from Attribute list):
    Update Target Record Document
    contactsIds=suppliers.contactsIds

    Workflow test 2 for Document after record created (works but CPU 100% and timeout):
    ​$spl_id=suppliersId;
    $doc_id=id;
    $contact_ids=record\attribute('Suppliers', $spl_id, 'contactsIds');

    $i=0;
    while ($i < array\length($contact_ids),(
    $contact_id=array\at($contact_ids,$i);
    record\relate('Document', $doc_id, 'contacts', $contact_id);
    )
    );​

    ​This issue is only with Document-entity. Workflow with copy contacts works fine with other entities:
    Update Target Record RFxLines
    Contacts
    Field: Requests.contacts
  • yuri
    Member
    • Mar 2014
    • 8440

    #2
    Hi,

    Moved our from the bug reports. If some formula not being working, it's not a bug in almost all cases. This is more a request for help than a bug report.

    1. Document does not have contacts link-multiple field.

    2. Your formula does not have iteration on $i.




    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • rouhu
      Member
      • Sep 2020
      • 39

      #3
      Indeed, after adding $i=$i+1; it worked.

      Comment

      Working...