Copy link to clipboard
Copied
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
Use "&&" instead of "+".
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 += "...";
Copy link to clipboard
Copied
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...";
Copy link to clipboard
Copied
Use "&&" instead of "+".
Copy link to clipboard
Copied
Wow it really was as simple as that! Thank you very much!
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Sure. You can do it like this:
if (/BCD/.test(this.getField("Text1").valueAsString) && this.getField("Dropdown1").valueAsString=="No") emailBody += "...";
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Do you mean either "ABC", or "DEF", or "GHI" all require the same number?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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 += "...";
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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...";
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
So you may have serial number like the following:
AAAA12345BCD12345
AAAA12345EFG12345
AAAA12345HIJ12345
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more