Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Dropdown selection changes email

Explorer ,
Nov 15, 2022 Nov 15, 2022

Hello,

I have a checking in form that when submitted (depending of dropdown selections) auto fills an email with part descriptions and part numbers, this is working fine. I am updating it for other reasons but I was wondering if it is possible to have the email auto populate with different part numbers depending on the selection of part made in a dropdown? 

So if part 1 is selected (screen) then part number for selection 2 (harness) changes?

 

On top of this is it possible that if the screen and harness are missing from the machine can Adobe search part of the serial number of the machine to identify which screen and harness it should have?

 

Hopefully that makes sense!

 

Thanks

 

TOPICS
Acrobat SDK and JavaScript
1.9K
Translate
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 2 Correct answers

Community Expert , Nov 15, 2022 Nov 15, 2022

Use "&&" instead of "+".

Translate
Community Expert , Nov 15, 2022 Nov 15, 2022

I recommend looking up some information about boolean operators and logical conditions in general, and in JS in particular. In this specific scenario the code would be something like this:

 

var c1 = /ABC/.test(this.getField("Text1").valueAsString);
var c2 = /DEF/.test(this.getField("Text1").valueAsString);
var c3 = /GHI/.test(this.getField("Text1").valueAsString);
var c4 = this.getField("Dropdown1").valueAsString=="No";
if ((c1 || c2 || c3) && c4) emailBody += "...";

 

Translate
Explorer ,
Nov 15, 2022 Nov 15, 2022

I can appreciate that this doesnt work but something like this?

 

if (this.getField("2").valueAsString=="C1000" + this.getField("6").valueAsString=="No")
emailBody += "\nC1000                               700...";

 

if (this.getField("2").valueAsString=="NT03" + this.getField("6").valueAsString=="No")
emailBody += "\nNT03                               701...";

Translate
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
Community Expert ,
Nov 15, 2022 Nov 15, 2022

Use "&&" instead of "+".

Translate
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 ,
Nov 15, 2022 Nov 15, 2022

Wow it really was as simple as that! Thank you very much!

Translate
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 ,
Nov 15, 2022 Nov 15, 2022

Is there a way for the code to check a a text box for 3 specific letters (there are 17 letters and digits maximum) and for example:

AAAA12345BCD12345

 

then once found update the email to add another part/ part number if a drop down has been selected as no?

 

Thanks

Translate
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
Community Expert ,
Nov 15, 2022 Nov 15, 2022

Sure. You can do it like this:

if (/BCD/.test(this.getField("Text1").valueAsString) && this.getField("Dropdown1").valueAsString=="No") emailBody += "...";

Translate
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 ,
Nov 15, 2022 Nov 15, 2022

excellent! how would I go about doing it so that it can find serial number changes?

So: ABC,DEF,GHI may require one part and part number but JKL,MNO,PQR is another and so on?

Thanks

Translate
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
Community Expert ,
Nov 15, 2022 Nov 15, 2022

Do you mean either "ABC", or "DEF", or "GHI" all require the same number?

 

Translate
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 ,
Nov 15, 2022 Nov 15, 2022

Sorry, yes each serial number will have 3 letters that are the year it was made but changes may only occur every 3 years. so ABC, DEF, GHI will require one part number and the others will require a different one

Translate
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
Community Expert ,
Nov 15, 2022 Nov 15, 2022

I recommend looking up some information about boolean operators and logical conditions in general, and in JS in particular. In this specific scenario the code would be something like this:

 

var c1 = /ABC/.test(this.getField("Text1").valueAsString);
var c2 = /DEF/.test(this.getField("Text1").valueAsString);
var c3 = /GHI/.test(this.getField("Text1").valueAsString);
var c4 = this.getField("Dropdown1").valueAsString=="No";
if ((c1 || c2 || c3) && c4) emailBody += "...";

 

Translate
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 ,
Nov 15, 2022 Nov 15, 2022

Thank you very much! 

is there anyway for it to search for a range rather than an individual number? so ABC, DEF, GHI are one group and JKL, MNO, PQR is a second and so on?

 

Where would be the best place to read up on boolean? or is it better once i have a rough understanding to just mess around with it?

 

Thanks

Translate
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
Community Expert ,
Nov 15, 2022 Nov 15, 2022

This is not a range, though. They are just different string.

 

For more info see here:

https://www.w3schools.com/js/js_booleans.asp

https://www.w3schools.com/js/js_comparisons.asp

 

Translate
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 ,
Nov 15, 2022 Nov 15, 2022

Can I not just create a variable that contains all of the serial number letters so something like:

var a1 = ABC + DEF + GHI etc?

then all i would need to do would be to have the something like the following code:

var c3 = /a1/.test(this.getField("Serial No").valueAsString);

if  (c3 && c4) emailBody += "\n...";

Translate
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
Community Expert ,
Nov 15, 2022 Nov 15, 2022

Probably, but you'll need to read about an even more complicated subject, called Regular Expressions.

However, you can use an array of strings and then test each one of the items in it, like this:

 

var serialNumbers = ["ABC", "DEF", "GHI"]
var c1 = false;
for (var i in serialNumbers) 
	c1 = c1 || new RegExp(serialNumbers[i]).test(this.getField("Text1").valueAsString);
Translate
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 ,
Dec 02, 2022 Dec 02, 2022

So if c1 is false this will search the var serialNumbers for one of those 3 specific letter combinations in the specified text field? to make it search through multiple serial number ranges I would duplicate that code but use something like the following:

 

var serialNumbers2

var c2 

etc

 

once ive done that how do I set it up to add this to the email body? using something like this?

 

var c4 = this.getField("Dropdown1").valueAsString=="No";
if ((c1  && c4) emailBody += "...";

 

Thank you

 

 

Translate
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
Community Expert ,
Dec 02, 2022 Dec 02, 2022
LATEST

There's only one variable now. All the serial numbers go into the serialNumbers array, and at the end of the process the value of c1 will be true if any of them is found.

Translate
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 ,
Nov 15, 2022 Nov 15, 2022

So you may have serial number like the following:

AAAA12345BCD12345

AAAA12345EFG12345

AAAA12345HIJ12345

 

Translate
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