Skip to main content
Jul 19, 2018 7:28 AM UTC
Solved

Delete Infotable row based on selected row values

var size = me.Intruders.getRowCount();
var i=0;
for (i=0;i<size;i++)
{
if (me.Intruders.rows.Age == Intruders.Age){
DeleteItem(i);
break;
}

}
function DeleteItem(i)
{ if(i!=0){
me.Intruders.RemoveRow(i);
}
}

 

This is not working , can someone help?

Intruders.Age is a selected row infotable (input parameter) and I am looking to delete a row from Intruders infotable with the Age from selected row.

Aug 15, 2018 8:14 AM UTC

var size = me.Intruders.getRowCount();
var i;
for (i=0;i<size;i++)
{
if (me.Intruders.rows[i].Age == Intruders.Age){
result = "nice";
var myTempTable = me.Intruders;
myTempTable.RemoveRow(i);
me.Intruders = myTempTable;
break;
}

}

 

Thank you for the help, here is the working code if someone needs it.

It deletes the date based on row parameter.

5 replies

Jul 19, 2018 8:13 PM UTC

When you say this is not working, are you getting errors?

Is the infotable persisted or not?

you are doing a direct in memory operation which would mean that is the infotable is persisted, it will retain the original content after a thing restart or system restart.

 

Jul 20, 2018 9:44 AM UTC

There are no errors, Yes the infotable is presisted.

The Service does not delete a row because the infotable is persisted ?

After the executions, the specific row is still there. It doesn't delete it.

Jul 20, 2018 5:10 PM UTC

To make a persistent delete in an InfoTable property you have to completely re-write the property

so 

myTempTable = me.Intruders

myTempTable.RemoveRow(i)

me.Intruders = myTempTable

Jul 20, 2018 2:49 PM UTC

Try accessing the value of the property directly. Use +me.Intruders.rows.Age in your if condition statement.

Like : if (+me.Intruders.rows.Age == Intruders.Age). 

AleksandarAuthorAnswer
Aug 15, 2018 8:14 AM UTC

var size = me.Intruders.getRowCount();
var i;
for (i=0;i<size;i++)
{
if (me.Intruders.rows[i].Age == Intruders.Age){
result = "nice";
var myTempTable = me.Intruders;
myTempTable.RemoveRow(i);
me.Intruders = myTempTable;
break;
}

}

 

Thank you for the help, here is the working code if someone needs it.

It deletes the date based on row parameter.