RecordRef to RecordRef

mgmmgm Member Posts: 126
With a Sales Header record, I want to get the E-mail adress of a Customer.
I made a general function to do this and it works fine.
GetEmailTableID(RecRef : RecordRef) : Text[80]

CASE RecRef.NUMBER OF
  36,110,112,114:
    BEGIN
      RecRef2.OPEN(18);
      FieldRef2 := RecRef2.FIELD(1);
      FieldRef2.VALUE := FORMAT(RecRef.FIELD(2)); //="Sales Header"."Sell-to Customer No."
      IF RecRef2.FIND('=') THEN BEGIN
        FieldRef := RecRef2.FIELD(102);
        EXIT(FieldRef.VALUE);
      END;
    END;


But is there an easier way to get the second RecordRef io. the above?
Something like RecordRef2.GET(RecordRef......) ?

Comments

  • reijermolenaarreijermolenaar Member Posts: 256
    Yes, the above example can be shorter because the second recordref is not needed.
    Just add the customer table as a local variable.
    IF RecRef.NUMBER IN [36, 110, 112, 114] THEN BEGIN
      Cust.GET(RecRef.FIELD(2).VALUE);
      EXIT(Cust."E-Mail");
    END;
    
    Reijer Molenaar
    Object Manager
  • mgmmgm Member Posts: 126
    Thanx Reijer,

    It's an option. But I don't want to declare a record variable, like Customer.
    I want to link other tables as well in the same function, so make the function with as least variables as possible.
    That's why I want to use a second RecordRef variable.

    Maarten
Sign In or Register to comment.