get value for first id of linked entities

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • diyoyo
    Member
    • Jul 2018
    • 88

    get value for first id of linked entities

    Hi,
    I have an entity A that is linked in a Many-To-Many relationship to an entity B.
    When creating a new A, I want to do the following flow:
    - if A has not been linked to any B in the creation form, then A.name is required
    - if A has been linked to at least one B in the creation form, then A.name is not required
    - if A.name is empty and at least one B is linked to the new A, then A.name becomes B[0].name

    I have a problem with the last part.
    here is my formula for A, concatenating 'Bonjour' to the first Id of Bs as a test of validity:

    Code:
    ifThen(name==null && bsIds!=null && array\length(bsIds)>0, name=string\concatenate('Bonjour',bsIds[0]));
    But even with this simple test, bsIds[0] does not return anything.
    Also, I had tried the condition bsNames!=null and array\length(bsNames)>0 but bsNames seems to be empty, compared to bsIds (which means that my next question will be : how to retrieve bsNames[0] instead of bsIds[0] ?)

    Thanks.
  • jurnet
    Member
    • Aug 2019
    • 35

    #2
    Have you solved your problem ? I try to do the same thing

    Comment

    • yuri
      Member
      • Mar 2014
      • 8440

      #3
      In the next version there will be the new function record\findRelatedOne
      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

      Working...