Jump to content
Salesforce and other SMB Solutions are coming soon. ×

deleting an invoice made by mistake makes next invoice come with wrong number


eledal

Recommended Posts

Hi everybody

I've got an invoice table and number of the invoice is given by a serial number

If I create an invoice by mistake and I delete it, next invoice will come with the wrong number. Is there an automatic (and simple since I'm a novice smiley-smile ) way to make the serial number to start from the one of the last invoice?

Thank you for your kind help

Link to comment
Share on other sites

Yes.

 

Run this script after deleting the unwanted record, but before creating its replacement:

 

Show All Records

Go to Record [Last]

Set Variable [$UtmostSerial, Invoices::Serial Number]

Set Next Serial Value [invoices::Serial Number, $UtmostSerial+1]

 

 

Note that if Invoice #31512 is an Invoice that you do not want, and you have already created Invoices 31513 and 31514, this script isn't going to do anything for you. Deleting 31512 at this point is going to leave a hole. Period. The other two aren't going to "slide back" and take up the empty space.

Link to comment
Share on other sites

Hi Alan

Why not do that with one script step:

 

Set Next Serial Value [invoices::SerialNumber, 
      GetNextSerialValue ( Get ( FileName ) ; "Invoices::SerialNumber" ) - 1]

 

It still has the same caveat as your solution. But it is a simpler way to just roll back the serial number by one. smiley-wink

Link to comment
Share on other sites

Thank you for your kind help...I was trying David Head solution which is supposed to be the simple one (and sure it is...not in my inexperienced hands !!Oh Really! smiley-smile )...I've got some problem in script making...Okay I tell you what I did (in astep to step manner...as I was a 3 years old child and maybe when using fmp I'm just 1 year old smiley-tongue-out ):

open script maker

new

name of the new script dopo elimina fattura (which means after having deleted an invoice)

From the column at the left of the blank space I insert Set Next Seral value

then click move

and now I begin to have some problems...I suppose I have to click on calculated result specify

I do that....and then??? If I try to copy the script as you wrote it in the blank field of the specify calculation window (substituting invoices::serial number with my fatture::numero fattura) and so this way:

 

fatture::numero fattura,

GetNextSerialValue ( Get ( FileName ) ; "fatture::numero fattura" ) - 1

 

fmp tells me this number cannot be evaluated and the "," between numero fattura and Get... flashes...

What's wrong (except that i'm not goof for fmp smiley-wink ??) again

Thank you

Link to comment
Share on other sites

There should be TWO buttons at the bottom: one to specify what FIELD is the field for which you are resetting the next serial value — that's the top one — and, below it, a second button to specify WHAT TO SET IT TO.

 

Whenever someone uses this kind of nomenclature:

 

Some Script Step [TableName::Field, "Some Value"]

 

that is FileMaker-ese for

 

a) click the top button and specify the part before the comma or semicolon in that first dialog;

 

b) click the bottom button and specify the part after the comma or semicolon in that second dialog.

 

 

In some cases the top and bottom button will be down at lower right below all the script steps, as is the case with Replace Field Contents and Set Field; in some cases you'll only see a single "Specify" button but when you click it you'll end up with a dialog which has places to type values and/or new buttons to click to specify "top" and "bottom" params, as is the case with Set Variable or Change Password.

 

 

You'll also see variations in what the target is to be set to: sometimes it will obviously be a field value, sometimes a literal string, sometimes a calculation or FileMaker function:

 

Some Script Step [TableName::Field, "Some Value"]

 

Some Script Step [TableName::Field, SomeTable::AnotherField]

 

Some Script Step [TableName::Field, 2 * Sum (RelatedTable::SomeField) & Case (Get(CurrentDate) ≤ $DueDate, "something else"]

 

... but the underlying logic is still the same. Noun, then verb. First comes the object, then comes the specified value that is being deployed unto that object.

Link to comment
Share on other sites

Why not change your invoice # into an auto-enter calc. Setup a relationship from Invoices to Invoices, making it cardinal (X).

 

The auto enter calc would be:

 

Max ( Invoices::Invoice Number ) + 1

Link to comment
Share on other sites

As was pointed out in a previous thread, it's less bulletproof; especially in a multi-user environment, the above, and many other such routines, can result in identical "serial numbers" when two users go to create a record at the same time.

Link to comment
Share on other sites

This thread is quite old. Please start a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

Terms of Use