Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Inserting multiple subforms instances with app.response on click event.

josh12468112
Level 2
Level 2

I could use some help sorting out this click event. I can't seem to get it to work the way I need it too. I have tried a few different variations with no success. The part I am having trouble with is in the loop and inserting multiple copies based on user input from the app.response event. I have a version of script that works with no loop but that won't allow functionality for inserting multiple instances of the subform. Would appreciate any help figuring out how I can do this.

var cChoice = app.popUpMenu("Add a blank section",  "Copy this section", "-", "Delete this section");

if(cChoice == "Add a blank section"){

ACT.instanceManager.addInstance(1)

} else if(cChoice == "Delete this section"){

ACT.instanceManager.removeInstance(this.parent.instanceIndex)

}else if(cChoice == "Copy this section"){

var cResponse = app.response("How many instances of this section would you like to insert?",["Copy current section",])

}

if (cResponse == null)

{

app.alert("No copy of the current section was inserted due to a null response.");

}

else

{

var i=ACT.instanceIndex

var j=0

while(j<cResponse)do

{

_ACT.addInstance(1)

xfa.resolveNode("form1.Subform1.ACT[" +(i+1) + "].Row1.textField").rawValue = xfa.resolveNode("form1.Subform1.ACT.Row1.textField").rawValue

1 Accepted Solution
_Bruce_Robertson
Correct answer by
Level 10
Level 10

Hi,

You code has got a bit mangled , but maybe something like;

var cChoice = app.popUpMenu("Add a blank section",  "Copy this section", "-", "Delete this section");

if(cChoice == "Add a blank section")

{

    ACT.instanceManager.addInstance(1)

}

else

if(cChoice == "Delete this section")

{

    ACT.instanceManager.removeInstance(this.parent.instanceIndex)

}

else if(cChoice == "Copy this section")

{

    var cResponse = app.response("How many instances of this section would you like to insert?",["Copy current section",])

    if (cResponse == null)

    {

        app.alert("No copy of the current section was inserted due to a null response.");

    }

    else

    {

        var i=ACT.instanceIndex

        var j=0

        while(j<cResponse)

        {

            var act = _ACT.addInstance(1)

            act.Row1.textField.rawValue = xfa.resolveNode("form1.Subform1.ACT.Row1.textField").rawValue

            j++;

        }

    }  

}

 

View solution in original post

0 Replies
_Bruce_Robertson
Correct answer by
Level 10
Level 10

Hi,

You code has got a bit mangled , but maybe something like;

var cChoice = app.popUpMenu("Add a blank section",  "Copy this section", "-", "Delete this section");

if(cChoice == "Add a blank section")

{

    ACT.instanceManager.addInstance(1)

}

else

if(cChoice == "Delete this section")

{

    ACT.instanceManager.removeInstance(this.parent.instanceIndex)

}

else if(cChoice == "Copy this section")

{

    var cResponse = app.response("How many instances of this section would you like to insert?",["Copy current section",])

    if (cResponse == null)

    {

        app.alert("No copy of the current section was inserted due to a null response.");

    }

    else

    {

        var i=ACT.instanceIndex

        var j=0

        while(j<cResponse)

        {

            var act = _ACT.addInstance(1)

            act.Row1.textField.rawValue = xfa.resolveNode("form1.Subform1.ACT.Row1.textField").rawValue

            j++;

        }

    }  

}

 

View solution in original post

josh12468112
Level 2
Level 2

‌Yeah I had tried so many different variations I think I mangled it pretty good.

That did the trick! Thank you!!!!!