Announcement

Collapse
No announcement yet.

Create related record for each value in multi-enum field

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

  • Create related record for each value in multi-enum field

    I have a multi-enum field in my Entity. When the user saves, I want to create a related record for each value selected in the multi-enum.

    Can I create a "For Each" type loop in a Formula?

  • #2
    This code must work with you:

    Code:
    $i = 0;
    
    while(
       $i < array\length(processes),
       (
          $id = record\create(
             'SubTask',
             'name', array\at(processes, $i)
          );
    
          entity\addLinkMultipleId('subTasks', $id);
    
          $i = $i + 1;
       )
    );
    This will create a new entity for every item on processes and link it to the task, you can change it to fit your needs.
    Processes is a Multiple enum field on task
    CEO of Eblasoft
    EspoCRM Expert since 2014
    Full Stack Web Developer since 2008
    Creator of Numerous Successful Extensions & Projects​

    Comment

    Working...
    X