Create related record for each value in multi-enum field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zaShadow
    Junior Member
    • Jun 2021
    • 3

    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?
  • eymen-elkum
    Active Community Member
    • Nov 2014
    • 472

    #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...