Link by formula generated document fom document to related entity

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1828

    #1

    Link by formula generated document fom document to related entity

    I have a formula, which generates a document, sends it by email and at the same time stores it into a folder in documents.
    I would like to have this document in the same process to be linked to the entity, from which the generating process started.
    Currently I use the default n:n relationship between this entity and documents.
    I could also create another relationship as 1:1 if it would make it easier.
  • yuri
    EspoCRM product developer
    • Mar 2014
    • 9611

    #2
    Do you use solely formula or Workflow/BPM tools?

    You can utilize record\relate function https://docs.espocrm.com/administrat.../#recordrelate

    Comment


    • shalmaxb
      shalmaxb commented
      Editing a comment
      solely formula
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1828

    #3
    This is my formula:

    $ids = record\findRelatedMany('Document', id, 'documents', 10);
    record\relate('myEntity', id, 'documents', $ids);

    but it does not work.

    Comment

    • yuri
      EspoCRM product developer
      • Mar 2014
      • 9611

      #4
      It's hard to tell without knowing the structure of your entities.

      $ids = record\findRelatedMany('Document', id, 'documents', 10);

      This would be relevant if your formula is execute from the Document entity type and the Document entity type has the relation called "documents".

      Comment


      • shalmaxb
        shalmaxb commented
        Editing a comment
        Thanks yuri. Then it is this, I need it the other way round. I will try again.
        Besides that I wish you continuing success with the best CRM and a happy New Year.
    Working...