Skip navigation
Currently Being Moderated

Identify and remove a particular instance

Sep 19, 2012 12:13 PM

Tags: #javascript #livecycle #instance #resolvenode #removeinstance

I need some assistance with this. I have a checkbox which creates an instance in a seperate form when checked. It creates, gives values to dropdown lists in that instance, and moves it to the end of all the previous instances just fine.

 

I cant seem to get the removeal of this field to work when the checkbox is deselected. Since users have the ability to reorder instances I cant just remove the last instance, I need the removal to happen based on the value of the dllField when that value = "Text"

 

Here is my code:

 

//CheckBox value
varValue=this.rawValue

//Checkbox = unchecked
if (varValue==0)
{
//remove instance where ddlField = "Text"
var instanceOCRRem = xfa.form.RicohStandardEDDForm.Page6.sub18ExportFieldedDataFields.subc oncordancefields.subRows.subRow.resolveNode("subRow").ddlField.rawValu e="Text"
xfa.form.RicohStandardEDDForm.Page6.sub18ExportFieldedDataFields.subc oncordancefields.subRows.subRow.instanceManager.removeInstance(instanc eOCRRem);
}
//Checkbox = Checked
else if (varValue==1)
{
//add instance, set the value of the ddlField and ddlECapField, then move it to the end of all the previous instances
var instanceOCR = xfa.form.RicohStandardEDDForm.Page6.sub18ExportFieldedDataFields.subc oncordancefields.subRows.subRow.instanceManager.insertInstance(1,true)
var nIndexFrom = instanceOCR.resolveNode("subRow").index;
var instanceCount = xfa.form.RicohStandardEDDForm.Page6.sub18ExportFieldedDataFields.subc oncordancefields.subRows.subRow.instanceManager.count -1;
instanceOCR.ddlField.rawValue="Text"
instanceOCR.ddlECapField.rawValue="OCR Text"
instanceOCR.resolveNode("subRow").instanceManager.moveInstance(nIndex From,instanceCount);
};

 
Replies
  • Currently Being Moderated
    Sep 20, 2012 11:38 AM   in reply to NickTransue

    You need a loop to go through the instances to find the one you want.

     

    I've uploaded a quick sample here:

    https://acrobat.com/#d=HCE5l51RbmjfxSkjGIZbDA

     

    I've just done one subform (subHolder) with a repeating subform inside it (subRepeat). It presents multiples of a repeating subform with the index displayed and a textfield that you can type into, if the value of the textfield is "text" it will remove that subform when you click off the checkbox.

     

    var vInstances = this.resolveNodes("subHolder.subRepeat[*]"); 
    
    if (this.rawValue == 1){
              subHolder._subRepeat.addInstance(1);
    }
    else{
              for (i = 0; i < vInstances.length; i++) {
                        if (vInstances.item(i).TextField2.rawValue == "text"){
                                  vInstances.item(i).instanceManager.removeInstance(i);
                        }
              }
    }
    

     

    You can shorten your add routine by using addInstance() instead of insertInstance() + moveInstance() - addInstance() puts the object at the end.

     

    The underscore before the repeating object is a shortcut to the instanceManager.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points