Expand my Community achievements bar.

Pass an InstanceManager item to a global function

Avatar

Former Community Member

Apparently the 2 lines below do not pass the instance of Item to the global function, or I am referencing the instance incorrectly in the fucntion, which is the bottom part.  Can someone help me with the proper syntax to allow a function to work on an instance in a LiveCycle form?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

var rowInstance = this.parent.parent._Item;

 

script_object.deletetheRow(testMe, rowInstance);

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

form1.#variables[0].#script[0] - (JavaScript, client)

function deletetheRow(testMe, rowInstance)

{

rowInstance.removeInstance(this.parent.index);
}

3 Replies

Avatar

Level 10

Hi,

I would pass the object that called the function and then work from there within the function.

script_object.deletetheRow(this);

Then the function

function deletetheRow(oObject) {

     oObject.parent.parent._item.removeInstance(oObject.parent.index);

}

Niall

Avatar

Former Community Member

Thank you for the response, Niall.

The problem with passing the object is that the row name is not consistent in all tables that will call the function.  I am calling it from a cell in the row, and would want, in this case, to delete the entire row.  I am trying to use a function because I am doing some other things to validate the deletion first, and would liek to avoid repetative code for each table.

Karl

Avatar

Level 10

Hi,

That shouldn't matter, provided the hierarchy structure is the same, eg the same number of parents to get to the repeating object.

Also in your script the removeInstance parameter being expressed as "this.parent.index" wouldn't work, as the function does not know what "this" is. In my version it might need nother .parent, depending on your structure.

Niall