Expand my Community achievements bar.

SOLVED

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

Avatar

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

Avatar

Correct answer by
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

2 Replies

Avatar

Correct answer by
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++;

        }

    }  

}

 

Avatar

Level 2

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

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