Skip to main content
16-Pearl
April 29, 2024
Question

Unable to delete Row from infotable with function myInfoTable.RemoveRow(rowIndex);

  • April 29, 2024
  • 1 reply
  • 1543 views

 

let entry = Things["Allied_Entries_SCW1.DT"].GetDataTableEntryByKey({key:"1713786015000SCW1E-AS-02"});

logger.info(entry.rows);

entry.rows[0].versionData.RemoveRow(0);

 

versionData is an infotable but i am still not able to remove the row with its index. As you can see this is an infotable why i am unable to remove it. any idea please?

 

Jamal8548_0-1714397471888.png

<========================================================================================================>

 

FURTHER TESTING

 

 

I am removing row and updating that entry with removing that row but it is removing row at run time means i get what i want as an output but it not updating it in datatable. Anyone has an idea?

1 reply

17-Peridot
April 29, 2024

You need to update again into the data table.

Allied_Entries_SCW1.DT

Use following services.

AddOrUpdateDataTableEntry()
or 
AddOrUpdateDataTableEntries()

 

MA873117416-PearlAuthor
16-Pearl
April 30, 2024

I am already doing this but it is not working as it returns the result on runtime correct but not updating the entry into datatable.

@PaiChung any idea?

 

 

let entry = Things["TestBench_Entries_SCW1.DT"].GetDataTableEntryByKey({key:"1709109105000SCW1E-SCW-EMT-06"});



 let values;
if ( entry.rows[0].versionData && entry.rows[0].versionData.rows && entry.rows[0].versionData.rows.length > 1 ) {

 let newVersionData = entry.rows[0].versionData;
 
 
 
 values = Things["TestBench_Entries_SCW1.DT"].CreateValues();
 values.entryTimeStamp = entry.rows[0].entryTimeStamp; // STRING [Primary Key]
 values.Location 		 = entry.rows[0].Location; // INFOTABLE
 values.Position = entry.rows[0].Position; // DATETIME
 values.entryDate = entry.rows[0].entryDate; // STRING
 values.status = entry.rows[0].status ; //"SCW1Phase4";// STRING // To change the status of the main entry 
 values.tinNumber = entry.rows[0].tinNumber;// STRING
 values.versionData = newVersionData.RemoveRow(9); //entry.rows[0].versionData;// STRING
 
}




Things["TestBench_Entries_SCW1.DT"].AddOrUpdateDataTableEntry({values:values});
result = entry;

 

 

 

MA873117416-PearlAuthor
16-Pearl
April 30, 2024

I got a solution for this issue which is very weird and i could not understand that why it is behaving like that but at least i have a solution now.

 

 

let entry = Things["TestBench_Entries_SCW1.DT"].GetDataTableEntryByKey({key:"1709109105000SCW1E-SCW-EMT-06"});


 let values;

 let newVersionData = entry.rows[0].versionData.RemoveRow(9); // this wil remove the row and then idk how we are updating the entry in the datatable but it is working actually
 
 
 
 values = Things["TestBench_Entries_SCW1.DT"].CreateValues();
 values.entryTimeStamp = entry.rows[0].entryTimeStamp; // STRING [Primary Key]
 values.Location 		 = entry.rows[0].Location; // INFOTABLE
 values.Position = entry.rows[0].Position; // DATETIME
 values.entryDate = entry.rows[0].entryDate; // STRING
 values.status = entry.rows[0].status ; //"SCW1Phase4";// STRING // To change the status of the main entry 
 values.tinNumber = entry.rows[0].tinNumber;// STRING
 values.versionData = entry.rows[0].tinNumber; //entry.rows[0].versionData;// STRING
 





Things["TestBench_Entries_SCW1.DT"].AddOrUpdateDataTableEntry({values:values});
result = entry;