0

Duplicate a quote a change its number

Hello,

I have a quote table. On «Trigger on new record», I have that script:

let myLastNumber := last(((select Quote where 'Quote #') order by 'Quote #').number(extractx('Quote #', "\d+")));
'Quote #' := "OF" + format(myLastNumber + 1, "000000")

It works fine when I create a new quote, a new value is assigned to  Quote #.

I have created a duplicate button:

let newRecord := duplicate(this);
alert("The quotation was duplicated");
popupRecord(newRecord)

My problem is that the quote number changes on the first record and not on the new, who keeps the old value.

4 replies

null
    • szormpas
    • 1 mth ago
    • Reported - view

     Hi, it looks like you have the same problem as discussed in this post.

    My advice for the duplicate button is to avoid using the duplicate function and instead create a new record and then copy the fields you want into the new record, except from the 'Quote#' field.

    • Fred
    • 1 mth ago
    • Reported - view

    Depending on how many fields that need to be duplicated, you can always put the Quote# code into your button so it will do the exact same thing as when you create a new record.

    • Mel_Charles
    • 1 mth ago
    • Reported - view

    I use a button to duplicate (copy my quotes along with the child table for quote line entries  to a new quote. and give them a new number as follows belwo

    This is my script on my button (the quote number ie QteNum increases to the next available number and of course I reset the date etc.

    let before := max((select Quotes).QteNum);
    let xQte := QteNum;
    let newRecord := duplicate(this);
    openRecord(newRecord);
    newRecord.(OldRef := QteNum);
    newRecord.(QteNum := before + 1);
    newRecord.(Status := "Live");
    newRecord.(OldRef := xQte);
    newRecord.(Revised := true);
    newRecord.(QteDate := today())

      • pascalp
      • 1 mth ago
      • Reported - view

       Yeah, it works. Thank you, thank you.

Content aside

  • Status Answered
  • 1 mth agoLast active
  • 4Replies
  • 47Views
  • 4 Following