I have a piece of code that works 90% the other 10% occasionally it breaks and I receive the "record has never been selected" error. I've checked smmActivities table up and down and while I'm sure there's something I'm missing it just isn't evident to me. Is there something my code is missing? Why does it work sometimes and other times it doesn't?
This code is meant to reassign open activities to a worker when assigned to new territory.
Thanks in advance,
Doug
static void AssignActivitiesByCustomer(Args _args)
{
CustTable _custTable;
smmActivityParentLinkTable _smmActivityParentLinkTable;
smmActivities _smmActivities;
while select * from _custTable where _custTable.MainContactWorker == HcmWorker::findByPersonnelNumber("000297").RecId
{
while select * from _smmActivityParentLinkTable where _smmActivityParentLinkTable.RefTableId == 77 && _smmActivityParentLinkTable.RefRecId == _custTable.RecId
{
_smmActivities = smmActivities::find(_smmActivityParentLinkTable.ActivityNumber, true);
if(_smmActivities.Closed == NoYes::No)
{
if(_custTable.MainContactWorker != _smmActivities.ResponsibleWorker)
{
_smmActivities.ResponsibleWorker = _custTable.MainContactWorker;
_smmActivities.update();
}
}
}
}
info("Complete");
}