Expand my Community achievements bar.

SOLVED

Email pdf form to field value and actual email address

Avatar

Level 7

I have a couple of issues I'm trying to solve and am not sure how to proceed. I need the Submit button to pick up a value from a field that the user has filled in and I need to supply an email address.

I need to provide the text for the subject line of the email plus add a value from a field that the user fills in.

I got those two elements to work based  on scripts I got from the Forum.

But I also need the top half (or first page) of the form to be sent as a pdf and the second half (or second page) to still be an interactive form and a submit button that works similarly to the first Submit button.

How can I accomplish this? Apparently, I'm still not able to attach a copy of the form.

Thanks in advance.

MDawn

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

I would recommend Paul Guerette's sample "LockAllFields". You can use this to lock all of the fields on page 1 before the PDF is saved and emailed. This will leave the objects on page 2 as interactive/"fillable inable".

I think Paul's sample passes "form1" into the function. You would need to change this to "page1" so that it only locks the objects on that page.

You will not be able to split the PDF form into two.

Good luck,

Niall 

View solution in original post

18 Replies

Avatar

Correct answer by
Level 10

Hi,

I would recommend Paul Guerette's sample "LockAllFields". You can use this to lock all of the fields on page 1 before the PDF is saved and emailed. This will leave the objects on page 2 as interactive/"fillable inable".

I think Paul's sample passes "form1" into the function. You would need to change this to "page1" so that it only locks the objects on that page.

You will not be able to split the PDF form into two.

Good luck,

Niall 

Avatar

Level 7

Thank you

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Level 7

I found Paul's script. Can I make the script part of clicking on the Submit button rather than a separate button? How would I do that?

Thanks,

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Level 10

Try Paul's call to the LockAllFields function in the mouseUp event and your email script in the click event. That should work.

N.

Avatar

Level 7

Thanks.

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Level 7

I tried this and was unable to get it to work. In Paul's sample it says:

myScriptObject.LockAllFields

Does the myScriptObject stay in the statement?

Also, what kind of event is mouseUp?

Do you put the script on mouseUp with the Submit button selected or no?

Thanks again for all your help.

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Level 2

If you look at the Hierarchy (Right Side of screen) move your Variables (myScript Object) to the master page, then change the script to all your document title, the Name above your master pages title ie:

myScriptObject.LockAllFields(Employment);

. Also would suggest to change your button from "moveup" to "click"

This will allow both pages to lock prior to submission. hope this helps. i just went through the same process

Avatar

Level 10

Hi,

If you want only parts of the form to be locked at any one time, then I wouldn't move the script object from its standard location (below the root node).

In Paul's example the script object is called "myScriptObject", you can leave this as it is. When you are calling the "LockAllFields" function you will reference the script object that contains the function. That is why Paul's script in the click event of the button contains the name of the script object AND the name of the function.

You can place script in different events for a button. More often than not you are putting script into an interactive event. There is mouseEnter and mouseExit, which represent the user interacting with the button but not actually clicking it.

Button script events.png

There is a mouseDown event, which is fired as the user starts to click the button. This is not a good event to script against, as the user has not fully committed to clicking the button. They could move the mouse off the button while it is still pressed, effectively canceling the click.

Two useful events to script a button are mouseUp and click. They are very similar, both effectively firing once the user has confirmed the click.

Over time I have found that if you are packing a lot of functionality/script into the click event, then the first portion may not have fully committed when the remainder of the script fires. This is why I suggested moving the first portion (lock all fields) into the mouseUp event - it gets that process out of the way before the email steps.

So, if you call Paul's script object and pass the name of page 1 into the function in the mouseUp event, this will fire first. Then in the click event you can have your email script.

I have an example of events firing here, which may be of interest: https://acrobat.com/#d=gQsdhRtm*K8xDIzZirfLcw

Hope that helps,

Niall

Avatar

Level 7

Thanks.

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Level 7

Thank you. I really appreciate your detailed explanation. I'm learning JavaScripting email by email!!

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Level 7

I think I did this exactly as instructed, but the LockAllFields is not working. Here is the line of script I put on the mouseUp event of the Submit by Email button:

myScriptObject.LockAllFields (page 1);

What am I missing? The email works fine, and I'm not getting an error message.

Thanks again for everyone's help.

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Level 10

Hi Margaret,

I am guessing that the forum has put in the spaces in your script(?)

Here is a screenshot of Paul's form:

LockAllFields.png

You will see that Paul is passing "form1" through to the function. This is the name of the root node, so when clicked it will lock everything.

If this form had multiple pages and just just wanted to lock the first page "purchaseOrder", then the script would look like this:

myScriptObject.LockAllFields(purchaseOrder); 

A couple of things to watch out for:

  • The script object "myScriptObject" is under the root node in the hierarchy;
  • That the script object name in your event matches the name in the hierarchy;
  • That the function name in the script matches that in the script object;
  • The script object name and function name should be different and also do not use reserved words like "node";
  • The name you are passing through to the function should match the name of a container in the hierarchy

A couple of things you can try would include setting up a trial button and having the script in the click event, just to get it working.

Also when previewing the form, press Control + J to open the javascript console. Then when you click the button, it will return any problem that is making the script fall over. This then makes it easier to find a solution.

Hope that helps,

Niall

PS Just spotted that the script object is not under the root node. This isn't an issue here because there is only one page and the button calling the script object in under the same node. As far as I know if you have multiple pages that call the script object, then it is better to have the script object under the root node, where it is available from all pages.

Avatar

Level 2

There is a space between myScriptObject.LockA llFields (page 1); you need to make it like so..

myScriptObject.LockAllFields(page 1);

Also you will need to place the script variables in the form hierarchy as well if you have not done so. If you have then make sure of the following:

Snipit from Niall O'Donovan

A couple of things to watch out for:

  • The script object "myScriptObject" is under the root node in the hierarchy;

  • That the script object name in your event matches the name in the hierarchy;

  • That the function name in the script matches that in the script object;

  • The script object name and function name should be different and also do not use reserved words like "node";

  • The name you are passing through to the function should match the name of a container in the hierarchy

See if that helps.

Avatar

Level 7

Thanks for your response.

I'm not sure what you mean by:

you will need to place the script variables in the form hierarchy as well if you have not done

Thanks again,

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Level 2

See Below picture, I have placed my variables under (Master Pages) due to having two pages.

Avatar

Level 7

Thanks, I'll give this another try!

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Level 7

I'm not able to access the picture.

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065