Setting Multiple Key Fields with RECREF and FIELDREF

rsaritzkyrsaritzky Posts: 439Member
Hi all,

Does anyone know if you have a table with a multi-field key and want to set a range/filter on that table in a RecordRef, do you need to define and use multiple FieldRef variables? For example, Table 81 Gen. Journal Line has a primary key = "Journal Template Name,Journal Batch Name,Line No.". If I want to SETRANGE on Journal Template name and Journal Batch name, do I need 2 FieldRef Variables or can I use just 1, e.g. can I do this?:
FieldRef := GenJnlLineRecordRef.FIELD(1);  //Field 1 is Journal Template Name
FieldRef.SETRANGE(MyJournalTemplateName);
FieldRef := GenJnlLineRecordRef.FIELD(51);  //Field 51 is Journal Batch Name
FieldRef.SETRANGE(MyJournalBatchName);
IF GenJnlLineRecRef.FINDFIRST THEN....

OR do I need this?
FieldRef1 := GenJnlLineRecordRef.FIELD(1);  //Field 1 is Journal Template Name
FieldRef1.SETRANGE(MyJournalTemplateName);
FieldRef2 := GenJnlLineRecordRef.FIELD(51);  //Field 51 is Journal Batch Name
FieldRef2.SETRANGE(MyJournalBatchName);
IF GenJnlLineRecRef.FINDFIRST THEN....

Has anyone tried both versions?

Thanks

Ron
Ron

Answers

Sign In or Register to comment.