Announcement

Collapse
No announcement yet.

Copy value of field in one entity in another

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Copy value of field in one entity in another

    Hi, I have already attached this question to another thread, but it seems, that it does not get attention. I would really appreciate an explanation, why it does not work.


    Entity one has a tax field, from which I would like to hand over the value to entity two, so I wrote this formula:

    Code:
    taxFieldEntityTwo=linkEntityOne.taxFieldEntityOne;
    but it does not work. The entities are connected by n:n relationship.
    Any hint, what I am getting wrong?

    I also tried entity\getColumn, also without success.

    Thank you and my apologies for double post.

  • #2
    Hi,

    If the relationship is n:n then this will not work the way you mensioned.

    In addition to the following logic problem,

    If Entity2 has many related Entity1 then you have many tax values (one separated tax in every related Entity1).

    If you are sure that all related entities share the same value, then you can fetch the value from the first related entity if exist and set the target entity's field:

    PHP Code:
    $firstRelatedId array\at(entityTwosIds0);

    taxFieldEntityTwo record\attribute('EntityTwoName'$firstRelatedId'taxFieldEntityOne'); 
    Last edited by eymen-elkum; 01-19-2021, 10:57 AM.
    CEO & Founder of Eblasoft.
    Professional EspoCRM development & extensions.

    Comment


    • #3
      Thank you Eymen. Would it work with my formula, if it was a 1:n relationship? The origin tax is always only one tax value ( it is VAT), in the 2nd entity there would be n records, that would need this value.

      Comment


      • eymen-elkum
        eymen-elkum commented
        Editing a comment
        yes will work
    Working...
    X