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

Pass an InstanceManager item to a global function

Avatar

Level 3

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

Level 3

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