RecordRef.SetPosition(Text) Method
Version: Available or changed with runtime version 1.0.
Sets the fields in a primary key on a record to the values specified in the String parameter. The remaining fields are not changed.
Syntax
RecordRef.SetPosition(String: Text)
Parameters
RecordRef
Type: RecordRef
An instance of the RecordRef data type.
String
Type: Text
The string that is used to set the primary key. This string contains the primary key value to set.
Remarks
This method works the same as the SetPosition Method (Record).
Example
The following example changes the value in the primary key, the No. field, in table 23 (Vendor). Other fields are not changed. The code starts by opening table 23 (Vendor) as a RecordRef variable that is named MyRecordRef. The Field Method (RecordRef) selects the first field (No.) and stores the value in the MyFieldRef variable. The SetFilter Method (FieldRef) sets a filter that selects records from 10000 to 20000. The FindLast Method (RecordRef) finds and retrieves the last record in the record set. The SetPosition method changes the value in the No. field from 20000 to 20001. The record No. and the name of the record are displayed before and displayed again after the primary key value is changed. The string that contains the new primary key is initialized in the InputString variable.
var
MyRecordRef: RecordRef;
InputString: Text;
MyFieldRef: FieldRef;
Text000: Label 'The record No. before the primary key was changed is %1.\\ The vendor name before the primary key was changed is %2.';
Text001: Label 'The record No. after the primary key was changed is %1. \\ The vendor name after the primary key was changed is %2';
begin
InputString := 'No.=Const(20001)';
MyRecordRef.Open(23);
MyFieldRef := MyRecordRef.Field(1);
MyFieldRef.SetFilter('10000..20000');
MyRecordRef.FindLast;
Message(Text000, MyRecordRef.RecordId, MyRecordRef.Field(2));
MyRecordRef.SetPosition(InputString);
Message(Text001, MyRecordRef.RecordId, MyRecordRef.Field(2));
end;
The following is displayed before the SetPosition method is called:
The record No. before the primary key was changed is Vendor: 20000.
The vendor name before the primary key was changed is AR Day property Management.
The following is displayed after the SetPosition method is called:
The record No. after the primary key was changed is Vendor: 20001.
The vendor name after the primary key was changed is AR Day property Management.
Related information
RecordRef Data Type
Get Started with AL
Developing Extensions