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
-
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.
-
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.
-
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())
Content aside
- Status Answered
- 1 mth agoLast active
- 4Replies
- 47Views
-
4
Following