Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


automatically generate invoice number that would begin with a particular value

Explorer ,
Jul 15, 2021 Jul 15, 2021

Copy link to clipboard

Copied

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.

TOPICS
Comment review and collaborate PDF, JavaScript

Views

121

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Jul 15, 2021 Jul 15, 2021
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"...

Likes

Translate

Translate
Adobe Community Professional ,
Jul 15, 2021 Jul 15, 2021

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 15, 2021 Jul 15, 2021

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 15, 2021 Jul 15, 2021

Copy link to clipboard

Copied

Are these the check-boxes at the top of the page? So each time they click it should switch pattern? How would it know what was the last number used after the selection was changed? You would need to have two fields, showing/hiding them when each selection is made, and also incrementing their values.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 15, 2021 Jul 15, 2021

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 15, 2021 Jul 15, 2021

Copy link to clipboard

Copied

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;
}

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 15, 2021 Jul 15, 2021

Copy link to clipboard

Copied

Ok. i would try that and get back to you. thanks.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 15, 2021 Jul 15, 2021

Copy link to clipboard

Copied

SubhanAllah! it worked.

That's awesome. Thanks a lot. You're a genius

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 16, 2021 Jul 16, 2021

Copy link to clipboard

Copied

One more thing, please!

I want a particular field that would sum up all payments made thus far. that field should be locked from reset. and it would only sum up only when the form is submitted. if the value reaches a particular amount for the form user, the customer should now be discounted 3% of the product bought for the last payment made that hits that programmed target amount. there would also be an uneditable field that shows the target. Normally, he enjoys a 2% discount when he buys with cash and no discount on credit purchases. He/She should also not be able to access any part of the form until they click the cash or credit checkbox. The value vs target field should not add up any credit purchase. The customers are on the drop-down for Key distributors. I guess I have to create many fields on top of the value vs target field for the individual customer just as you helped out on the invoice numbering.

I hope this could be done! the form is attached. Thanks.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 16, 2021 Jul 16, 2021

Copy link to clipboard

Copied

I don't quite follow... Why do you only want to calculate it when the form is submitted? Why not have it always display the value? Or make it hidden altogether?

Also, I don't understand if you want to apply this discount if the value reaches a certain amount (if so, which one?), or if it's only for certain customers...

At any rate, this is getting a bit more complicated. If you're interested in hiring someone to set it all up for you feel free to contact me privately via [try6767 at gmail.com] and we could discuss it in more detail.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 16, 2021 Jul 16, 2021

Copy link to clipboard

Copied

The submitted part is not really important. the most important is when the customer reaches the target, then the discount is executed. all the customers are all registered with me. just a growing company I'm working on by the side. want to make it look attractive.

Thanks.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 16, 2021 Jul 16, 2021

Copy link to clipboard

Copied

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?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 16, 2021 Jul 16, 2021

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 16, 2021 Jul 16, 2021

Copy link to clipboard

Copied

I think you need to do more than that. Transparency is important, and may be a legal requirement. The customer needs to know exactly what the cost will be - even a surprise discount is not likely to be acceptable. So you need to show the correct discount and total before submitting, not as a surprise (no matter how pleasant).

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 16, 2021 Jul 16, 2021

Copy link to clipboard

Copied

The customers know the discount beforehand. it would be included on the app alert when he clicks on cash purchase field. So he would try to meet that target that would trigger the discount for him. just earlier said, the field would be connected to the customer list on the dropdown.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 18, 2021 Jul 18, 2021

Copy link to clipboard

Copied

Hello try,

I just transferred this script to another form and changed the prefix to capital letters and is returning NaN. What do I need to change?

Thanks

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 18, 2021 Jul 18, 2021

Copy link to clipboard

Copied

I can't say without seeing the file in question.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 30, 2021 Jul 30, 2021

Copy link to clipboard

Copied

Hi,

attached is a form you helped me with the script for automating doc. invoice number serially, how do I adjust the script to make it randomly, I realize that users might end up having duplicate invoice numbring.

Thanks.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 30, 2021 Jul 30, 2021

Copy link to clipboard

Copied

LATEST

I don't see the field where you want this to happen, but the general code is this:

 

this.getField("Invoice Number").value = util.printf("%06d", Math.floor(Math.random()*1000000));

 

This will generate a random 6-digit number.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines