For each array value?

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • esforim
    replied
    Originally posted by lazovic
    Thank you lazovic, I manage to fix it but output\printLine work fine in Sandbox but how would I do use it in an actual formula. I was meant to post this but forgot to Reply.

    Originally posted by espcrm
    Finally manage to figure it out, I need to do this:

    Code:
    $blocks = contactsIds;
    But the next issue is,
    Code:
    print(array\at($blocks, $i));
    This work fine for Sandbox, but how would you do it for Formula? I tried the following but error again.

    Code:
    $i = 0;
    $blocks = contactsIds;
    
    while ($i < array\length($blocks)) {
            $test=string\concatenate(
                $i,
            Contact ### ', record\attribute('Contact', array\at($blocks, $i), 'firstName'), '\n',
            record\attribute('Contact', array\at($blocks, $i), 'lastName'), '\n',
                                )
        ;
        $i = $i+1;
    }
    
    output\print($test)​
    I'm guessing it does not work with String\concatenate?​

    Leave a comment:


  • lazovic
    replied
    Hi esforim,

    Please try to use the following formula script in the Administration > Formula Sandbox (with Account Target Type):
    Code:
    $i = 0;
    
    $contactsIds = record\findRelatedMany('Account', id, 'contacts', 1000);
    
    while ($i < array\length($contactsIds)) {
        output\printLine(array\at($contactsIds, $i));
        $i = $i + 1;
    }​

    Leave a comment:


  • esforim
    replied
    Originally posted by Russ

    thanks
    Hi Russ, can you assist? How do you get the array ID to work?

    Code:
    $blocks = list('1','2','3');
    No problem if you do it like this, but the moment I add in the Array field, for example:

    Code:
    $blocks = list(contactsIds);
    It doesn't do anything meaningful

    Leave a comment:


  • Russ
    replied
    Originally posted by dimyy
    Use loop "while" for iterrate throw array
    For example:
    Code:
    $i = 0;
    $blocks = list('1','2','3');
    
    while ($i < array\length($blocks)) {
    print(array\at($blocks, $i));
    $i = $i+1;
    }
    ​



    If you need split string use https://docs.espocrm.com/administrat...g/#stringsplit
    thanks

    Leave a comment:


  • dimyy
    replied
    Use loop "while" for iterrate throw array
    For example:
    Code:
    $i = 0;
    $blocks = list('1','2','3');
    
    while ($i < array\length($blocks)) {
        print(array\at($blocks, $i));
        $i = $i+1;
    }
    ​



    If you need split string use https://docs.espocrm.com/administrat...g/#stringsplit

    Leave a comment:


  • Russ
    started a topic For each array value?

    For each array value?

    Hi, sorry for this basic question, I guess I couldn't find in the documentation.

    How do can I create a formula that will check the array of id's, and based on that array post into text fields a list of urls?

    Array example: 1,2,3

    Text field example:
    http://domain.com/?id=1
    http://domain.com/?id=2
    http://domain.com/?id=3

    Thanks
Working...