Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Protecting multiple instances in a subform

Avatar

Level 2

Working on a form which I want to access protect various subforms with a password that the user creates.

The script works ok apart from the AM11H.sfContent.sfRows subform, where it only protects the first instance. All other instances are unprotected.

var pword = AM11H.sfContent.sfPassCode.txtConCode.rawValue

if (AM11H.sfContent.sfPassCode.txtConCode.rawValue == pword) {

        AM11H.sfContent.sfProperty.access = "protected";

        AM11H.sfContent.sfNoAccess.access = "protected";

        AM11H.sfContent.sfRowHead.access = "protected";

        AM11H.sfContent.sfRows.access = "protected";

        AM11H.sfContent.stCompletedBy.access = "protected";

}

Can anyone help me with the script to lock all the instances of the AM11H.sfContent.sfRows subform. There are some 15 fields in the subform.

Thanks. 

1 Reply

Avatar

Level 2

You need use this for example:

var numInst = AM11H.sfContent.instanceManager.count;

if( numInst > 1)

{

     for( var i = 0 ; i < numInst ; i++ )

     {

          xfa.resolveNode("AM11H.sfContent[" + i + "].sfProperty").access = "protected";

     }

}

else

{

     AM11H.sfContent.sfProperty.access = "protected";

}

ZAMPAZAMPA