These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Dynamic emails based on a condition

adjmcloon
Registered: Jan 8 2010
Posts: 13

Hello,

I have an order form that gets routed around the office to different people based on a couple of conditions. All has been working well..the submit button for the form is at the bottom of the first page.

Recently I added a 2nd page to the pdf to capture referral information. I updated my script to look at a field on the 2nd page and set a CC address. For some reason though, it doesn't work. Is the coding different to select a field that is not on the active page?

The "ref" variable in the 1st section is calling the field on the 2nd page of the pdf, fyi. I've obviously got some syntax wrong because I get "missing } after property list" 34:at line 35

Please be gentle, I'm an obvious n00b:

//Get variable values
var trade = this.getField("Trade").value;
var desc = this.getField("DESCRIPTIONRow1").value;
var total = this.getField("Total").value;
var ref = this.getField("RefName").value;

//PCI sheet processing
if (total > 0.00) {
var address = "orders [at] blah [dot] com"
}
else if (desc != "") {
var address = "orders [at] blah [dot] com"
}
else if (total = "0.00") {
var address = "otheruser [at] blah [dot] com"
}

//Check if referral is blank on page two - if not set CC address
if (ref != "") {
var refcc = "otheruser [at] blah [dot] com"
}

//Populate the subject line with customer and salesperson info
var cSubline = this.getField("CustomerName").value + " order, "
+ "Custno: " + this.getField("CustNo").value + " "
+ "Salesperson: " + this.getField("Salesperson").value;
var msgBody = "Press Send to submit your order for processing!";

//Send the Order as PDF
this.mailDoc({
bUI: false,
cTo: address,
cCC: refcc
cSubject: cSubline,
cMsg: msgBody,
cSubmitAs: "PDF"
})

My Product Information:
Acrobat Pro 9.0, Windows
try67
Online
Expert
Registered: Oct 30 2008
Posts: 2399
The parameter is called cCc , not cCC , and since JS is case-sensitive, it does not work.
The rest of the script is fine.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

try67
Online
Expert
Registered: Oct 30 2008
Posts: 2399
I wrote the rest of the script is fine, but in second look I've found another mistake.
this line:
else if (total = "0.00") {
Should be:
else if (total == "0.00") {

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

adjmcloon
Registered: Jan 8 2010
Posts: 13
Thanks.

I found a few other errors but I got it working. I also added some sales tax calculations, etc.

Is it not necessary to declare a global variable by using "var", but instead to just name the variable and what it should equal? So instead of var somevariable = x after an if statement, is it good form to use just somevariable = x (without the var) if I don't need to declare a global variable?

My next project on this form is to have it pull up a shipping calculator that asks weight, value and destination zip code and then looks at a table to get shipping cost. Anyone have any pointers?

Thanks! I am really enjoying teaching myself javascript.
try67
Online
Expert
Registered: Oct 30 2008
Posts: 2399
Using "var" is not necessary.
I think it only comes into action when there are scope issues, for example if you have a recursive function that defines a variable in itself, then you need to use var. But most times it's not needed.

About your next project: sounds simple enough, but is the table you're looking for going to be read from a PDF, or just built-in to the script?

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

adjmcloon
Registered: Jan 8 2010
Posts: 13
Well, ideally it would interface with UPS Worldship since that's our primary carrier, but I would settle for a lookup based on a table, whether that table is external (ideal) or internal to the pdf. As long as I can get close to the shipping cost it will work. I need to calculate weight, value (important) and of course destination zip code.

Could you point me to some resources? I am having hell trying to find some examples to learn from.