Set
class is used for the storage and retrieval of data from a collection in which the values of the elements contained are unique and serve as the key values according to which the data is automatically ordered.Solution with Sets
Declare set in Form\class declaration
Set setChangedRecord;
Initialize set on Form\DataSource\init as follows:
setChangedRecord = new Set(Types::Record);
Store records in set on Write method of the data source as follows
if (!setChangedRecord.in(purchReqLine))
{
setChangedRecord.add(purchReqLine);
}
{
setChangedRecord.add(purchReqLine);
}
Traversing of records in Set:
Following is the way of traversing records from Set
SetEnumerator setEnumerator = setChangedRecord.getEnumerator();
while (setEnumerator.moveNext())
{
reqLine = setEnumerator.current();
if (!reqLine.IsSaved)
{
purchReqLineLocal = PurchReqLine::findRecId(reqLine.RecId,true);
purchReqLineLocal.IsSaved = true;
purchReqLineLocal.update();
}
{
reqLine = setEnumerator.current();
if (!reqLine.IsSaved)
{
purchReqLineLocal = PurchReqLine::findRecId(reqLine.RecId,true);
purchReqLineLocal.IsSaved = true;
purchReqLineLocal.update();
}
}
Aucun commentaire:
Enregistrer un commentaire