7 Replies Latest reply on Dec 17, 2010 12:53 PM by Dresden89

    How to set a field as 'office use only'

    Dresden89 Level 1

      Hello all,

      I have one more question for you. 

       

       

      I sometimes send forms out that must have information set in the fields. The problem is that I don't want the people I send the forms to to change this information. Is there an easy way to do this?

       

      Thanks,
      Tristan

        • 1. Re: How to set a field as 'office use only'
          George_Johnson MVP & Adobe Community Professional

          Just make the fields you don't want edited read-only. If you have a reset button, also set the default value to the field value, which you can do with the following Validation script for any such text fields:

           

          //Validate script for text field

          event.target.defaultValue = event.value;

          • 2. Re: How to set a field as 'office use only'
            George_Johnson MVP & Adobe Community Professional

            Here's a link to a similar topic that might help with setting the field easily: http://forums.adobe.com/message/3313693

            1 person found this helpful
            • 3. Re: How to set a field as 'office use only'
              Dresden89 Level 1
              This is EXACTLY what I would want. Where do I set up a bookmark?
              I changed the prefixes to private.NAME and copy paste the code into a button that executes Java but it didn't work. Sorry, I'm such a noob at this.

               

               

              Both suggestions seem good, but I would

              have about 10 or more fields that I would need to change everytime I send or recieve the pdf.

              Is there a way to make the process easier? The form I'm trying to make would also need to be used by other people in the office who are not as tech savy as I am... and that is not saying much.



              There are a number of ways. Probably the simplest is to set up a bookmark that prompts the user for a password. If correct, it would lock/unlock the fields. This would all be implemented in JavaScript. You can do the same type of thing though the use of a custom menu item or toolbar button.




              Try something like:


              (function () {


                  // Get one of the fields in the group
                  var f = getField("private.name");


                  // Determine new readonly state, which
                  // is the opposite of the current state
                  var readonly = !f.readonly;


                  var readonly_desc = readonly ? "deactivate" : "activate";


                  // Ask user for password
                  var resp = app.response({
                      cQuestion: "To " + readonly_desc + " the fields, enter the password:",
                      cTitle: "Enter password",
                      bPassword: true,
                      cLabel: "Password"
                  });


                  switch (resp) {


                  case "your_password": // Your password goes here
                      getField("private").readonly = readonly;
                      app.alert("The fields are now " + readonly_desc + "d.", 3);
                      break;


                  case null : // User pressed Cancel button
                      break;


                  default : // Incorrect password
                      app.alert("Incorrect password.", 1);
                      break;
              }


              })();



              In this example, the fields that are controlled by this all have a field name prefix of "private", for example "private.name", "private.address", etc. This makes it easier to control the fields as a group, as I do in the line of code that begins: getField("private").readonly  If you don't use such a field naming convention, you'd have to have a separate such line for each field in the group.


              Replace "your_password" above with one of your own. The first and last lines are not necessary, but do prevent the needless creation of document-global variables, which is a good thing.

               

              • 4. Re: How to set a field as 'office use only'
                George_Johnson MVP & Adobe Community Professional

                Reply,  To set up a bookmark in a document, first display the Bookmarks pane:View > Navigation Panels > Bookmarks

                 

                Add a new one by clicking the little icon with a gold star. It will default to a caption of "Untitled" with an action of "Go to a page i this document". Rename the bookmark to what you want and then right-click and select Properties > Actions

                 

                Delete the default action and add a new JavaScript action with the code I showed.

                 

                Note that all of the field names that you want to control need to have the "private" prefix. For example:

                 

                private.name

                private.address

                private.po_num

                 

                and so on. The decimal separator is important. You can use some other prefix other than "private", but it has to be consistent and the code needs to be modified to account for a different prefix.

                 

                Once you have the bookmark set up and show the other users how it works, it should be easy for them to work with.

                1 person found this helpful
                • 5. Re: How to set a field as 'office use only'
                  Dresden89 Level 1

                  I'm really trying not to be obtuse but nothing happened after I made the bookmark.

                   

                  I did exactly as you said making the bookmark. I changed all the field names to be private.Name of Insured, private.Medicare, private.Other Insurance Name.

                   

                  I'm sure there is some rookie thing I'm missing. Thanks for lining stuff out like that though

                   

                  Edit: I have them writable by default, should I make them read only by default?

                  • 6. Re: How to set a field as 'office use only'
                    George_Johnson MVP & Adobe Community Professional

                    It's probably something simple. I'd be happy to take a look at the form if you're free to email it to me: acroscript at gmail dot com

                    • 7. Re: How to set a field as 'office use only'
                      Dresden89 Level 1

                      In case anyone else has this issue, here is the problem I had

                       

                      From George: You just needed to change "private.name" in the first line to match one of  the private fields on the form.

                       

                       

                      Thanks so much!