formula multiplefile = multiplefile problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brotherlouie
    Junior Member
    • May 2023
    • 12

    formula multiplefile = multiplefile problem

    Hello, I searched the forum for a similar topic for about an hour but couldn't find it. If there is one and I'm sorry for reopening this topic.

    The problem I'm experiencing is as follows. I have two multiple additional fields. And I want to synchronize them with a formula.

    For example, I want the images I added to my field1 field to appear in field2.

    I did this in a simple way, my formula is as follows;

    field1Ids = field2Ids;
    field1Names = field2Names;
    field2Types = field2Types;

    This formula works at the first save stage. (image1)
    disappears when I refresh the page. (image2)

    I hope I explained it. Can you help?
    Attached Files
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1602

    #2
    Could you give some more information?What field type did you use?

    Comment

    • Ashif Malayil
      Senior Member
      • Dec 2023
      • 171

      #3
      Hello,
      You can try using just one formula: field1Ids = field2Ids. However, this approach may not work as intended because it maps the values of Field 2 to Field 1, which might not be the desired operation. Instead, you should use the formula field2Ids = field1Ids, as this correctly maps the values from Field 1 to Field 2`.

      Comment

      • brotherlouie
        Junior Member
        • May 2023
        • 12

        #4
        shalmaxb hello, I used the Attachment Multiple field.

        Comment

        • brotherlouie
          Junior Member
          • May 2023
          • 12

          #5
          Ashif Malayil hello, I tried it with one formula, but I can't get any results.
          I have three options when writing a formula. fieldId, fieldName and fieldType. I tried all of them individually and it didn't work. I tried them both as binary and it still didn't work.

          Comment

          • lazovic
            Super Moderator
            • Jan 2022
            • 809

            #6
            Hi brotherlouie,

            In this case, you need to create attachments again with a formula script and bind them to a new field. Here you can see an example of working with attachments in a formula script: https://forum.espocrm.com/forum/deve...-email-formula.

            Comment

            • brotherlouie
              Junior Member
              • May 2023
              • 12

              #7
              Hi lazovic,

              I understand what you said. I like this perspective. However, this solution seems to affect my disk space. Am I right? Because it will create another copy for the attachments I add (jpg, png, pdf). And it will affect my disk space as much as the file sizes. The same attachment will be saved more than once.

              I want the same files to appear as read-only. Do you have a different suggestion for this?

              Comment

            • lazovic
              Super Moderator
              • Jan 2022
              • 809

              #8
              brotherlouie,

              There is no other solution, this is the logic that is currently established. Each attachment in EspoCRM has its own place; even if it is an absolute duplicate, it must fully "exist".

              Comment

              • shalmaxb
                Senior Member
                • Mar 2015
                • 1602

                #9
                if you add an attachment to a field (attachment multiple or image) it will always be physically present in your upload folder and any of these attachment will get an id of its own. It will be the same, if you copy the attachment by formula. With the mentioned field types, you will get a physical copy and this is treated like a new upload.
                the only way I see is to copy the URL of that attachment to the copy field, which you could achieve with a text field, where you concatenate the path and id. In this case, you will only see a link in the copied field.
                I think copying by formula and displaying a present file in the attachments two times will not be possible.

                Comment

                • brotherlouie
                  Junior Member
                  • May 2023
                  • 12

                  #10
                  lazovic and shalmaxb thank you very much for your help.
                  https://forum.espocrm.com/forum/deve...-email-formula I tried to do something based on this link but I couldn't. I don't want to waste your time. I tried to adapt the formula according to the code in the link. I tried all variations. (I don't know how to code) I couldn't. Can you take a look at the code logic one last time?

                  My main entity's name is EasyFlow. The fields I'm trying to copy are in the same entity. One is called offermultiplefile and the other is called offerkopya. I want to copy the files added to the offermultiplefile section to the offerkopya field.

                  I have changed the fields in the formula many times. The last one I tried is as follows.Of course, most of the fields mean nothing to me. (Since I don't know how to code )


                  $i = 0;

                  $offerMultipleFileIds = list();

                  while(

                  $i < array\length(offerkopyaIds),
                  $offerkopyaIds = array\at(offerkopyaIds, $i);

                  $offerMultipleFileIds = record\create('EasyFlow',
                  'role', 'EasyFlow',
                  'type', record\attribute('EasyFlow', $offerkopyaIds, 'type'),
                  'size', record\attribute('EasyFlow', $offerkopyaIds, 'size'),
                  'global', record\attribute('EasyFlow', $offerkopyaIds, 'global'),
                  'name', record\attribute('EasyFlow', $offerkopyaIds, 'name'),
                  'sourceId', $offerkopyaIds,
                  'storage', record\attribute('EasyFlow', $offerkopyaIds, 'storage')
                  );

                  $offerMultipleFileIds = array\push($offerMultipleFileIds, $offerMultipleFileIds);

                  $i = $i + 1;

                  );


                  Thank you again for your help.

                  Comment

                  • shalmaxb
                    Senior Member
                    • Mar 2015
                    • 1602

                    #11
                    It is always difficult to understand the intention of other users, because you have to know a bit about the app and what you wnt to achieve.
                    Perhaps ist would help, if you would describe, what this is all about. I have some kind of guessing, that it could be solved completely different.
                    Sometimes you get an idea of a possible solution, because you do not know yet espoCRM in every detail of possibilities. I only can state, that I already had so many surpising success, because espoCRM is excellently thought and programmed.
                    Saying this, let`s not give up.

                    Comment

                    • brotherlouie
                      Junior Member
                      • May 2023
                      • 12

                      #12
                      Hi shalmaxb. I have an entity named "EasyFlow". I have two fields in this entity where I will add multiple files. My first field is called "offermultiplefield". My second field is called "offerkopya".

                      I want the files I add to the "offermultiplefield" field to be automatically created in the "offerkopya" field. And I need a formula that triggers this.

                      The problem I mentioned at the beginning of the form was that the formulas below did not work.

                      offerkopyaIds = offermultiplefieldIds;
                      offerkopyaName = offermultiplefieldNames;
                      offerkopyaType = offermultiplefieldTypes;

                      lazovic said that this formula would not work and that I could create an example according to the formula script at https://forum.espocrm.com/forum/deve...-email-formula link and solve my problem. I tried to create a formula based on this.
                      And I couldn't. So I asked for yours help.

                      Comment

                      • lazovic
                        Super Moderator
                        • Jan 2022
                        • 809

                        #13
                        brotherlouie,

                        Please clarify: do you want to transfer several attachments from field offermultiplefile to field offerkopya? Please also check the names of these fields very carefully. This information is needed so that we can customize the formula script specifically for your case.

                        Comment

                        • brotherlouie
                          Junior Member
                          • May 2023
                          • 12

                          #14
                          lazovic yes I want to copy multiple attachments from offermultiplefile field to offerkopya field. the names of the fields are correct.

                          Comment

                          • shalmaxb
                            Senior Member
                            • Mar 2015
                            • 1602

                            #15
                            I believe, it is not possible without a nother upload this way. But I think - and that is what I meant in my last post - that you could create another entity for the files and link it two times to your entity Easy Flow, there you could choose from the file-Entity the files you need. In that case, the files would be linked and it would not be necessary to upload them again.
                            This is a possibility for a solution, but I did not test something like that. I think it is worth it though.

                            Comment

                            Working...