Announcement

Collapse
No announcement yet.

Create duplicate records automatically

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

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

  • #2
    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;
    };
    ​ 

    Comment


    • lazovic
      lazovic commented
      Editing a comment
      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.

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

    Comment

    Working...
    X