Here is the code behind the button which handles the marked records Martin, I had originally used this when the table was a standard table but it is now an InMemory one so I have changed the code slightly but you will get the jist of what I'm trying to achieve here.
Thanks for looking at this
void clicked()
{
CustomTable marking;
CustomRemoveTable removal;
MultiSelectionHelper selectionHelper = MultiSelectionHelper::construct();
;
if (Box::okCancel('Are you sure you wish to perform this?', DialogButton::Cancel) == DialogButton::Ok)
{
ttsBegin;
selectionHelper.parmDatasource(CustomTable_DS);
marking = selectionHelper.getFirst();
if (marking.RecId)
{
// loop through selected marked records and insert removal data then update record
while (marking)
{
// insert details of record for deletion if it is already there ignore it
try
{
// capture details in secondary deletion table
removal.clear();
removal.initValue();
removal.ItemCoverageRecId = marking.ItemCoverageRecId;
removal.CovDataAreaId = marking.CovDataAreaId;
removal.Processed = false;
removal.insert();
// delete marked record so user sees them being removed from their original selection
marking.selectForUpdate(true);
marking.MarkedForDelete = true;
marking.doUpdate();
}
catch(Exception::DuplicateKeyException)
{
continue;
}
marking = selectionHelper.getNext();
}
}
ttsCommit;
// refresh the datasource after completion
CustomTable_DS.research(true);
}
super();
}