Create duplicate records automatically

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • Emmker
    replied
    lazovic Was that you? Thank you.
    The unfinished one created endless records but I fixed that.
    Thanx again

    Leave a comment:


  • lazovic
    commented on 's reply
    Sorry if I misled you. Proposed formula script was unfinished and I wanted to finish it and send you the correct one. However, I'm glad I could help you.

  • Emmker
    replied
    With a modification of a code that someone posted here (and was deleted) I did it with:

    PHP Code:
    $n = quantity - 1;
    $i = 0;
    
    while($i < $n)
    {
       record\create('CLicense',
                     'licenseType', licenseType,
                     'kind', kind,
                     'serial', serial);
       $i = $i + 1;
    };​ 
    

    Leave a comment:


  • Emmker
    started a topic Create duplicate records automatically

    Create duplicate records automatically

    I have an entity 'CLicense' with a field 'quantity'.
    I am trying to have a formula to autocrate 'quantity -1' extra duplicate records when I save the original record.

    Trying to use the while function:

    PHP Code:
    $n = quantity -1;
    $count = record\count(CLicense, "serial", serial);
    
    while($count < $n)    
    {record\create(CLicense, 'licenseType',licenseType, 'kind', kind, 'serial', serial)};​ 
    
    I get error 500 when I am trying to save the original record.

    It is my first time with the while function and I am a bit lost here.
Working...