Expand my Community achievements bar.

SOLVED

Locking fields after Submit

Avatar

Level 1

Hello

I hope there is someone out there that can guide me in the right direction...

I have a PDF that has text fields that a user would fill out.  After its completed I would like to lock all the fields to read only BEFORE it is submitted via e-mail. That part I have figured out.  The problem is, when the PDF is opened when the e-mail recipient receives it, all the fields are editable again. I have tired different ideas on how to lock it, but none work.

Here is what I believe will work, but I don't know how to script it.  When the document is opened, in the initialize event, I would like to write a script that looks at TextField1 to see if there is any data in there.  If TextField1 is blank, the the PDF can be edited. If the TextField1 has any data, then the PDF is locked.

Here is a sample of what I mean:

------- form1.Page1.TextField1::initialize: - (JavaScript, client) --------

var LockTest=(TextField1).value

     {

     if (LockTest!="")   /* Checks the TextField1 for any data */

          myScriptObject.LockAllFields(form1);   /* if there is any data, lock the form */

     else

          app.alert(cMsg="Ready for edit",3,0);   /* if there is no data, lets begin editing */

     }

I have been playing with this for a few days and think I might be onto something. The only problem is, when there IS data in the field, the script doesn't see it and keeps the form unlocked.

Any ideas as to what I am doing wrong?

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 1

Just to let you all know....

I GOT IT!!!!

If anyone wants to know, here is what I've done.

The user fills out the form and hit the email button. The recipient opens the form and as this script fires:

------- form1.Page1::docReady - (JavaScript, client) ------

if (xfa.form.form1.Page1.TextField1.rawValue !=null)

     {

     myScriptObject.LockAllFields(form1);

     }

... and it works beautiful.  If they fill out the form and leave that field blank, the PDF is still editable.

I hope this helps someone else out... and thanks for reading

View solution in original post

1 Reply

Avatar

Correct answer by
Level 1

Just to let you all know....

I GOT IT!!!!

If anyone wants to know, here is what I've done.

The user fills out the form and hit the email button. The recipient opens the form and as this script fires:

------- form1.Page1::docReady - (JavaScript, client) ------

if (xfa.form.form1.Page1.TextField1.rawValue !=null)

     {

     myScriptObject.LockAllFields(form1);

     }

... and it works beautiful.  If they fill out the form and leave that field blank, the PDF is still editable.

I hope this helps someone else out... and thanks for reading