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

Javascript not defined error for dynamic email address generation from dropdown selection

New Here ,
Apr 17, 2023 Apr 17, 2023

Copy link to clipboard

Copied

Below javascript not working for cTo address but does work for cCc address. Error is "undefined." I am a newbie to writing javascript but researched this one to death and used a billion variations. This script is the only one that had no syntax errors. Where might the trouble be? My goal is to have the submit button send to first email if fulltime faculty is selected and to second email if any other item in dropdown is selected. I tried and else only statement and it failed. So I went with multiple if else statements. I also tried inequality ( != ) operator which also was a syntax error. Please advise! Thanks!

 

var DropdownPositionType = this.getField("DropdownPositionType").valueAsString;
if (DropdownPositionType === "Fulltime Faculty") {
event.value = "user@university.edu";
} else if (DropdownPositionType === "Graduate Assistant") {
event.value = "User2@university.edu";
} else if (DropdownPositionType === "Fulltime Staff") {
event.value = "User2@university.edu";
} else if (DropdownPositionType === "Parttime non student") {
event.value = "User2@university.edu";
}
var cCCAddr = this.getField("HiringManagerEmail").value;
var cSubLine = "Lorem ipsum dolor sit amet.";
var cBody = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.";
this.mailDoc({
bUI: true,
cTo: cToAddr,
cCc: cCCAddr,
cSubject: cSubLine,
cMsg: cBody
});

 

 

TOPICS
Acrobat SDK and JavaScript , Windows

Views

546

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

Community Expert , Apr 17, 2023 Apr 17, 2023

Replace

 event.value

with

 cToAddr

 

Votes

Translate

Translate
Community Expert ,
Apr 17, 2023 Apr 17, 2023

Copy link to clipboard

Copied

Where does you set the variable cToAddr? 

Votes

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
New Here ,
Apr 17, 2023 Apr 17, 2023

Copy link to clipboard

Copied

Hello Bernd,

Thank you for responding. I have no var for cToAddr. Only place I think it is set is in this.mailDoc. I do not know how else to define it. 

Votes

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
Community Expert ,
Apr 17, 2023 Apr 17, 2023

Copy link to clipboard

Copied

Replace

 event.value

with

 cToAddr

 

Votes

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
Community Expert ,
Apr 17, 2023 Apr 17, 2023

Copy link to clipboard

Copied

Do you want a new email to be sent each time the user makes a selection in the drop-down field?

Votes

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
New Here ,
Apr 18, 2023 Apr 18, 2023

Copy link to clipboard

Copied

No. The field is a one and done. User makes a single selection from dropdown field 'Position Type'.  An email is sent to recipient one when  "fulltime faculty" is chosen. Any other choice from that field will send an email to recipient two. 

Votes

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 ,
Apr 17, 2023 Apr 17, 2023

Copy link to clipboard

Copied

"Undefined" is not an error. 

Votes

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
New Here ,
Apr 18, 2023 Apr 18, 2023

Copy link to clipboard

Copied

So happy it is not an error. However I do not know how to fix and script does not work. 

Votes

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
Community Expert ,
Apr 18, 2023 Apr 18, 2023

Copy link to clipboard

Copied

Bernd just provided you with the solution. 

Replace "event.value" with "cToAddr".  This defines the cToAddr, so it can be used in the email fuction. 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
New Here ,
Apr 18, 2023 Apr 18, 2023

Copy link to clipboard

Copied

LATEST

Thank you so much Bernd and Thom! I made the change in the script and was elated after spending so much time on it and now it works perfectly. I appreciate the help. Thanks. 

Votes

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