we don't see how the s_MaxInvoiceNumber field is defined. Could the issue lies in there ? We are missing information here to help you.
What is your actual Max number? Is it an unstored calculation?
1 of 1 people found this helpful
For one thing, summary fields deal with the found set.
What is the found set when you are doing this operation?
Summary field performance gets worse as the found set gets larger.
The way you are using the summary function requires you to have a found set of all records.
(Or; a found set of highest-number records)
What are you really doing here?
Actually I followed a complete online course to get to this invoicing solution. I made changes but the core is build around the course I followed.
So what I need the solution to do is the following:
When I select "Invoice" from dropdown field "Invoices::Type" I need the "InvoiceNumber" to increment by 1.
When I select "Quote" from dropdown field "Invoices::Type" I need the "QuoteNumber" to increment by 1.
When the record is made I need it to be a quote standard. Which can be transformed into an invoice without having to make the entire thing from scratch.
I can post my complete solution here if you needed.
You may try an unstored calc field with Max(InvoiceNumber) and see if that helps.
Looks like your self join may have problems. Check to see what matcing records you are getting and what data is in that invoice number field.
Contrary to what others have posted here, your summary field is returning a max value based on a set of related records if I am correct that your layout is based on invoices as you are then referring to a summary field from a related table occurrence.
Would it make sense to keep a Invoices::MaxNumberInvoice (kinda like a counter field) and base the Invoices::InvoiceNumber on that +1 if Invoices::Type="Invoice".
In Belgium (my home country) all Invoices must be numbered serial. So if you delete record 24/24 the next invoice that you make should be 24. Unless it already exists and has the number 25.
I don't think auto serial works in that case?
Also a quote number should be easily transformed into an invoice so it automatically gets the last available number as InvoiceNumber.
I would make a script that
Set field Invoices::InvoiceDate = Get (CurrentDate)
Set field Invoices::InvoiceNumber = Invoices:MaxNumberInvoice + 1
Set field Invoices::InvoiceDate=""
Set field Invoices::InvoiceNumber = Invoices::MaxNumberInvoice - 1
Set field Invoices::QuoteDate = Get (CurrentDate)
Set field Invoices::QuoteNumber = Invoices:MaxNumberQuote + 1
Set field Invoices::QuoteDate=""
Set field Invoices::QuoteNumber = Invoices::MaxNumberQuote - 1
Like to hear your opinion on this.
The main issue is what happens if more than one user creates invoices at the same time. With both a "counter field" and the current method, it's possible for you to get two invoices with the same number simply because they got either the same "max value" or the same counter field value to which the script then adds 1. Make sure to at least include a unique values validation on that field.
But I'd recommend that you not allow an invoice to be deleted. Mark it "void" instead and design your solution to work with that accordingly. Then you can sequentially number your invoices and still account for those where a mistake would otherwise have caused you to delete the invoice.