Copy or Link Documents/Attachments from one Enity to another via Workflow?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • khopper
    Senior Member
    • Sep 2017
    • 329

    Copy or Link Documents/Attachments from one Enity to another via Workflow?

    I have a workflow that when an Opportunity is converted to an Account I can copy over the field values just fine.
    Is it possible to take any attachments in Documents or even a field with Multiple attachments and move/copy/link them to the newly created Account?

    I found there is an option to "Link with another Entity" in the workflow rules, however it wants me to choose a specific file/document/attachment that is already uploaded. which is not what I want.
    Last edited by khopper; 11-30-2017, 06:40 PM.
  • tanya
    Senior Member
    • Jun 2014
    • 4308

    #2
    Hello
    You can use action Upgrade Related Entity, select needed relation, and set in formula
    Code:
    parentId = targetEntity\attribute('accountId'); (or other field)
    parentType = 'Account';

    Comment

    • khopper
      Senior Member
      • Sep 2017
      • 329

      #3
      I don't have an option in actions to "Upgrade Related Entity", do you mean "Update Related Record"?

      Comment

      • tanya
        Senior Member
        • Jun 2014
        • 4308

        #4
        In different versions labels can be different as well. Of course.
        Also check, what field you need to set. It was just a tip.

        Comment

        • khopper
          Senior Member
          • Sep 2017
          • 329

          #5
          Tanya - this works perfectly for one of my fields however it does not work for documents???

          parentId = targetEntity\attribute('accountId');
          parentType = 'Account';

          Comment

          • tanya
            Senior Member
            • Jun 2014
            • 4308

            #6
            It works for all documents. But I asked you to check, what field has to be set for this relation

            Comment

            • khopper
              Senior Member
              • Sep 2017
              • 329

              #7
              Here is exactly what I am attempting to do.
              OPPORTUNITIES (Documents) --> Convert --> ACCOUNT (Documents)
              Make Sense?

              From what I can tell in the backend I want to take the documents from table 'document_opportunity' and move them to table 'account_document', the only thing both tables have in common is column 'document_id' - would 'document_id" be the relation?
              Last edited by khopper; 12-15-2017, 03:02 AM.

              Comment

              • tanya
                Senior Member
                • Jun 2014
                • 4308

                #8
                add to the rule opportunitiesIds=list(null);

                Comment

                • khopper
                  Senior Member
                  • Sep 2017
                  • 329

                  #9
                  Thank you Tanya!

                  I added what you suggested and its working 100% now!

                  Code:
                  accountsIds=list(targetEntity\attribute('accountId '));
                  opportunitiesIds=list(null);

                  Comment

                  • khopper
                    Senior Member
                    • Sep 2017
                    • 329

                    #10
                    I have a new Entity of PBX however when i adjust the formula its not working.

                    Changing this:
                    accountsIds=list(targetEntity\attribute('accountId '));
                    opportunitiesIds=list(null);

                    to this give me an error in the logs:
                    pbxsIds=list(targetEntity\attribute('pbxId'));
                    opportunitiesIds=list(null);

                    Also - just FYI "targetEntity" is not listed in the site for formulas https://www.espocrm.com/documentatio...ation/formula/

                    Please Help Anyone?
                    Last edited by khopper; 08-28-2019, 05:14 PM.

                    Comment

                    • khopper
                      Senior Member
                      • Sep 2017
                      • 329

                      #11
                      Maximus yuri tanya

                      I have tired several combinations but it is not making sense to me?

                      Comment

                      • Maximus
                        Senior Member
                        • Nov 2018
                        • 2731

                        #12
                        Hello,
                        Could you describe what are you trying to do? It is much better to understand what a logic you are trying to implement and then find a solution.

                        Comment

                        • khopper
                          Senior Member
                          • Sep 2017
                          • 329

                          #13
                          The Exact same thing I did previous except to a new entity.

                          When Opportunity Marked as "Closed Won" a workflow converts it to an Account (in this case "PBX") It copies the documents from Opportunity to the new Entity that was created via the workflow.

                          accountsIds=list(targetEntity\attribute('accountId '));
                          opportunitiesIds=list(null);

                          Comment

                          • khopper
                            Senior Member
                            • Sep 2017
                            • 329

                            #14
                            Maximus any update?

                            Comment

                            • Maximus
                              Senior Member
                              • Nov 2018
                              • 2731

                              #15
                              Hello Khooper,
                              sorry for the delayed reply. I have a few questions.
                              > I have a new Entity of PBX however when i adjust the formula its not working. To this give me an error in the logs: pbxsIds=list(targetEntity\attribute('pbxId')); opportunitiesIds=list(null);
                              What the error are appeared in the logs?
                              Have you made the same relation beetwen PBX and Documents as Acount has?
                              If yes, is the 'pbxsIds' is the proper name of the linked field?

                              Comment

                              Working...