How do you make a text field Read Only after it is saved and distibuted? | Community
Skip to main content
July 21, 2010
Solved

How do you make a text field Read Only after it is saved and distibuted?

  • July 21, 2010
  • 23 replies
  • 16555 views

How do you make a text field read only after it is saved and distibuted?

LiveCycle Designer ES 8.2

This JavaScript code on the exit event:

textField1.access = "readOnly";

This works after the user loses focus on the field, however after it is saved and distributed, that field is no longer "read-only".

I need to have staff insert information into a text field and then distribute it out to customers, and those fields have to be protected.

How do you do this?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by

No ....it must be there to be a valid schema....but it is not used by the product when offline.

Paul

23 replies

July 22, 2010

A common approach is to make the form non-interactive through a process often referred to as 'flattening'. There are a number of services available in the LiveCycle ES server suite to accomplish flattening.

In the absence of the LiveCycle ES server suite, flattening can be accomplished by printing the interactive form to PDF. The only requirement is that Acrobat would have had to have been installed on your desktop to enable printing to PDF.

Steve

July 22, 2010

Steve,

Thank you so much for getting back to me, I really appriecate it.

I found a post (http://forums.adobe.com/message/1958770#1958770) that had the following code, which works great for what I am needeing!

But, after I save the form as another name and reopen it, the fields are no longer protected.  Would "flattening" make it so.  And if I "flattened" my form will the dynamic table rows continue to work?  I don't know much about this Flattening process and this is the first I have heard about it, so I am a bit unsure if that is the route I need to take.

In the click event have something like this:

var nButton = app.alert({
    cMsg: "Warning after locking this alert, you will not be able to unlock it. \n\nDo you want to lock this alert?",
    cTitle: "Assure HSC",
    nIcon: 1, nType: 2
});
if ( nButton == 4 )
{
     // Get the field containers from each page.
     for (var nPageCount = 0; nPageCount < xfa.host.numPages; nPageCount++)

     {
          var oFields = xfa.layout.pageContent(nPageCount, "field");
          var nNodesLength = oFields.length;
          // Set the field property.
          for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++)

               {
                    oFields.item(nNodeCount).access = "protected"; // locks all fields
               }
     }
   
     // save value of lock
     Lock.rawValue = "1"; // sets the value of a flag

     quantityfield1.access = "open"; // specify the fields you want available to the client
     quantityfield2.access = "open";
     quantityfield3.access = "open";

     padlockopen.presence = "invisible"; // this is the static image of a padlock

}  

In the Layout: Ready event of the button, you would have a check on the value of the flag (Lock.rawValue):

if (Lock.rawValue == "0")
{
    // Get the field containers from each page.
     for (var nPageCount = 0; nPageCount < xfa.host.numPages; nPageCount++)

     {
          var oFields = xfa.layout.pageContent(nPageCount, "field");
          var nNodesLength = oFields.length;
          // Set the field property.
          for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++)

          {
               oFields.item(nNodeCount).access = "open"; // all fields open if Lock = 0
          }
     }

     padlockopen.presence = "visible";
}
else
{
    // Get the field containers from each page.
      for (var nPageCount = 0; nPageCount < xfa.host.numPages; nPageCount++)

     {
           var oFields = xfa.layout.pageContent(nPageCount, "field");
           var nNodesLength = oFields.length;
           // Set the field property.
           for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++)

               {
                     oFields.item(nNodeCount).access = "protected"; // locks all fields
                }
      }
    
     // save value of lock
     Lock.rawValue = "1"; // sets the value of a flag
    
     quantityfield1.access = "open"; // specify the fields you want available to the client
     quantityfield2.access = "open";
     quantityfield3.access = "open";

     padlockopen.presence = "invisible"; // this is the static image of a padlock

}

July 22, 2010

Flattening makes a interactive form an image essentially. All dynamic and interactive behaviour is removed.

Steve

July 22, 2010

So flattening is not the route I can take for this form, what other route would you suggest?

Eve Tracy

July 26, 2010

You are changing the "state" of the form. There is a setting in the Form Properties that indicates whether you want to save thses changes automatically

or you (the Form Designer) will take care of it. Look under File/Form Properties/Defaults and make sure that the Save Scripting changes is set to Automatically.

Paul

July 27, 2010

Thank you everyone for the help.  I ended up using the "secret space" method to make the text fields "Read Only" to users of the form and still giving staff the ablity to edit them.  I found this fix on forum link

http://forums.adobe.com/message/2582721#2582721 using the

SecretSpaceExample.pdf as an example.

Changing the form properties to run script Automatically fixed many of my issues.

Next - Need to figure out how to manipulate XML export data.  If anyone has a clue, I am listening.

July 27, 2010

You will want this command:

xfa.host.exportData("", false)

This will bring up a dialog box to allow you to select a filename and it will give an XML extension (it woudl be xdp if you do not include the false at the end).

Paul

July 27, 2010

So that will let me adjust how the form data is displayed in the xml export file?  What event would that command be on?

Right now, the fields that are on top of the form, those values appear at the bottom of the document when exported in XML..  My Oracle guys want the exported values in XML a certain way so they can import it correctly.

July 29, 2010

The XML data will follow the structure if the form in the hierarchy view unless you import a sample XML data file or you have a schema file (XSD). Then you can force the data to follow those structures by binding the field on th eform to the appropriate node in the data/XSD file.

paul

July 29, 2010

Morning Paul!

I am going through the XML schema tutorial on w3Schools http://www.w3schools.com/Schema/default.asp. to create the xsd file, it isn't as difficult as I thought it would be. I have the fields set correctly in the hierarchy so I will have to use the schema method to get the desired layout.

I have some concerns on binding it to the fields. Some fields have the binding set as global to populate other "read only" fields, will changing the binding to an xml schema affect the global bindings of those fields? If so, can I change the binding on the form/subforms or does it have to be on the individual fields?

Eve Tracy