I have a strategy that I used in one of my forms. At a certain point in the workflow, a type of user in the workflow would open the form and the requirement is to have the form read only for that type of user. So on a different form template, I used the below JavaScript on the layout ready event to make ALL the fields read only (it was quicker to do it this way instead of setting each field one by one, especially when a change is needed on all the forms), then I set the workflow fields and any other fields that I need to protected or open.
// 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 = "readOnly";
}
}
The code is from the Adobe_XML_Form_Object_Model_Reference.pdf produced by Adobe.
I hope it helps.
Stone.