FormDataSource.getFirst Method [AX 2012]
Retrieves the first record in a data set.
public Common getFirst([int mark, boolean fetchAhead])
Run On
ClientIf the mark parameter is not 0 (zero), the first record that is marked with the specified value is returned, and subsequent calls to the FormDataSource.getNext method return marked records.
If the fetchAhead parameter is set to false, only cached records are returned. If it is set to true, additional records are found and added to the cache, but the operation can become very time-consuming when it is performed on a large record set.
When records in a grid are multiselected, the records are marked with the value 1.
The following examples illustrate how to retrieve a marked or unmarked record: // Get first recordformDataSource.getFirst();// Get first record marked with 2formDataSource.getFirst(2); // Get first cached record marked with 1formDataSource.getFirst(1, false);
The following example determines whether two records are selected in a form.
boolean twoMarked()
{
SysVersionControlTmpItem tmpitem = this.getFirst(1);
if (!tmpitem)
{
return false;
}
tmpitem = this.getNext();
if (!tmpitem)
{
return false;
}
tmpitem = this.getNext();
if (!tmpitem)
{
return true;
}
return false;
}