Expand my Community achievements bar.

script to read name, convert to email address & add to To field on email message

Avatar

Level 1

This is my first experience with LiveCycle and Javascript. I am learning along the way.  I have a Return to Requestor submit button and need to write a script that on the mouseUp event, reads the name in the requestor field, converts the name to an email address and puts that address in the To field of the email to be returned to the requestor.  The Requestor field and Submit button in in the same subform.  Any help will be greatly appreciated.

6 Replies

Avatar

Level 10

Hi,

There are two examples here (one for users with Acrobat/Reader version 8 and lower; and one for users with Actobat/Reader version 9 or 10). In both cases you are looking at the last button which has a custom script.

http://assure.ly/eUR4wJ.

Take your time, it is a little bit involved.

Hope that helps,

Niall

Avatar

Level 1

Thank you Niall! I have added an email address field and wrote the script so that when the Requestor selects their name, their email is automatically entered into the Email address field. And it works! I am now working on the other script to create an email using the email address in the Email Address field. This is going to take time, it is very involved. I have a Submit button that the Requestor will click when he is ready to send his request to the “Gatekeepers”. The Gatekeepers are a group of 5 individuals. The Submit button is a Control Type Submit and their emails are listed in the Submit to URL: field. I need the Return to Requestor button to not only return the completed request back to the Requestor but to the five individuals who originally received the request. Where in the script I am writing now would I put those email addresses, they will be a constant?

Dee Perry

Gatekeeper

Invivo Diagnostic Imaging

3545 SW 47th Avenue

Gainesville, FL 32608

Phone (352) 336-0010 ext. 452

FAX (352) 336-1410

Avatar

Level 10

Hi Dee,

I'm away from the desk, so can't give detailed help. However if you look at this example (the third button), you will see how I'm declaring a CC variable.

http://assure.ly/eUR4wJ.

You could set the variable there in the script. For example:

var vCC = "me@company.com; you@company.com; them@company.com";

Then if you look at the email script you will see where I use the vCC variable.

Good luck,

Niall

Avatar

Level 10

Hi,

I correct this earlier in another post, the script should be:

var vCC = "&cc=me@company.com; you@company.com; them@company.com";

It was missing &cc=

Sorry,

Niall

Avatar

Level 1

I’m not getting it. Here’s my code:

//Construct email to return completed request to Requestor and Gatekeepers.

var vEmail;

var vCC = "&cc=john.grener@philips.com; johnathan.nichols@philips.com; mike.invivo.smith@philips.com<mailto:&cc=john.grener@philips.com;%20johnathan.nichols@philips.com;%20mike.invivo.smith@philips.com>";

//Check email address field and build error message.

if (emailAddress.rawValue ==null)

{

errorMessage = errorMessage + "\n - please provide an email address.";

}

else

{

vEmail = emailAddress.rawValue;

}

//Send email.

event.target.submitForm(;

I get a Microsoft Office Outlook does not recognize Deirdre.perry@companyname.com&cc=joe.glascock@companyname.com<mailto:Deirdre.perry@companyname.com&cc=joe.glascock@companyname.com>

So, I try to trouble shoot by removing Deirdre.perry@companyname.com<mailto:Deirdre.perry@companyname.com> and joe.glascock@companyname.com<mailto:joe.glascock@companyname.com>. I run another test, selecting another name from the Requestor field and I get a similar error message: Microsoft Office Outlook does not recognize hank.pate@companyname.com&cc=john.grener@companyname.com<mailto:hank.pate@companyname.com&cc=john.grener@companyname.com>.

I also have a syntax error somewhere on the last line of code that I can’t figure out yet. Writing code is not my regular job, but I am trying to learn.

Dee Perry

Gatekeeper

Invivo Diagnostic Imaging

3545 SW 47th Avenue

Gainesville, FL 32608

Phone (352) 336-0010 ext. 452

FAX (352) 336-1410