Skip to main content
Inspiring
July 15, 2021
Answered

automatically generate invoice number that would begin with a particular value

  • July 15, 2021
  • 1 reply
  • 3648 views

the subject matter has said it all. I am a novice to javascript. but I believe the script would be on the doc. script. can someone help me with this.ASAP.

Anyway, this is my first post on the community. Glad to be here.

Thanks.

This topic has been closed for replies.
Correct answer try67

Yes, the checkboxes are at the top. it's ok if the number is unique. Not to make things too complicated. but how should I go around that?

I might need to be spoon feed on this. I'm a big-time novice.

thanks


OK, try this: Create two read-only text fields, called "InvoiceID1" and "InvoiceID2" and place them one on top of another.

Then add this code as the Mouse Up event of both check-boxes:

 

if (event.target.value=="0") {
	this.getField("InvoiceID1").display = display.visible;
	this.getField("InvoiceID2").display = display.hidden;
	var prefix = "scd/fds/21/";
	var v = Number(this.getField("InvoiceID1").valueAsString.replace(prefix, ""));
	if (v==0) v = 5000000;
	else v++;
	this.getField("InvoiceID1").value = prefix + v;	
} else if (event.target.value=="1") {
	this.getField("InvoiceID1").display = display.hidden;
	this.getField("InvoiceID2").display = display.visible;
	var prefix = "scd/hh/21/";
	var v = Number(this.getField("InvoiceID2").valueAsString.replace(prefix, ""));
	if (v==0) v = 9000000;
	else v++;
	this.getField("InvoiceID2").value = prefix + v;
}

1 reply

try67
Community Expert
Community Expert
July 15, 2021

Actually, the subject line doesn't say nearly enough. When should this invoice number update? Does it need to be sequential? Random? Time-based? etc. Does it need to be unique?

 

A lot of information is missing for us to be able to help you with this.

saka5FD5Author
Inspiring
July 15, 2021
Thanks for the quick response.
the doc. num should be generated when the person clicks on a button in order to pick a category. it should be sequential but should begin with a particular value e.g., scd/fds/21/5000222 for button A and scd/hh/21/9000222 for button B. the highlighted being the standard value. I hope i make sense.

Thanks.
saka5FD5Author
Inspiring
July 16, 2021

You mean you want it to be able to refer to previous purchases (not on this form)? Or is this a calculation that can be done entirely from what the customer typed on this particular form?


What the customer typed on this particular form that met the target. The normal 2% discount should now be 3% with an alert congratulating him