Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Button to turn form access on and off?

Avatar

Level 1

Hi all,

I want to be able to click a button on a filled-in subform (form1.Data) to change its access from read-only to open (and back again).

I put a button on the master page (so i can still click the button when the subform is protected) with this IF statement, but it doesn't work. Sorry if it's a newbie mistake, but any idea why? Thanks.

If (form1.Data.access="open") then
    form1.Data.access = "protected"
else
    form1.Data.access = "open"
endif

1 Reply

Avatar

Level 10

Hi,

When testing for equality use a double ==.

Paul has an example of locking fields within a container (http://forums.adobe.com/message/2134982#2134982). It loops through all objects in a subform and locks them in turn.

Look at Paul's form, you will see a script object called "myScriptObject" in the hierarchy. There are a couple of ways to copy this into your form. The easiest is to create a script object in your form (right click on "form1" in the hierarchy and select "insert script object") and then name it "myScriptObject" or whatever name you want. Then copy all of Paul's function into your script object.

The function starts with:

function LockAllFields(myParentObject)

{

...

} // ends with closing bracket

LockAllFields = name of function

myParentObject = the name of the object that you specify when you call the function, e.g. "form1.Data" below.

You could have two functions in one script object. One would be Paul's to lock the objects and the second would be an adapted one to unlock the objects (change all "readOnly" to "open").

Your if statement would then look like in javascript:

if (form1.Data.textField1.access == "open") // test an object in Data subform

{
    myScriptObject.LockAllFields(form1.Data);
}

else

{
    myScriptObject.UnlockAllFields(form1.Data);
}

Give it a try,

N.