FieldRef and RecRef Question

nismo2006nismo2006 Member Posts: 22
Good Day,

I have a question regarding using references. I have a routine that dynamically grabs the table number from a recordset (110 = Sales Shipment Header), filters it based on certain criteria and gets records from that. I have all of these values stored in a Rec Ref and Field Ref variable. I then have to pass this information into an XMLPort and export it. The XML Port wants a specific filtered table but I can't figure out how to determine dynamically what table I am using and how to filter it. I cant pass the reference values. Is there anyway to define a variable to dynamically point to a specific table, filter it and pass it to the XML Port export. I appreciate the help in advance.


RecRef.OPEN(TableNo);
FelRef1 := RecRef.FIELD(EDIConfigRec.FieldFourToFilter);
FelRef2 := RecRef.FIELD(EDIConfigRec.FieldTwoToFilter);
FelRef3 := RecRef.FIELD(EDIConfigRec.FieldOneToFilter);
FelRef4 := RecRef.FIELD(EDIConfigRec.FieldThreeToFilter);

FelRef1.SETFILTER('%1',EDIConfigRec.FieldFourFilterValue);
FelRef2.SETFILTER('%1',EDIConfigRec.FieldTwoFilterValue);
FelRef3.SETFILTER('%1',EDIConfigRec.FieldOneFilterValue);
FelRef4.SETFILTER('<>%1',EDIConfigRec.FieldThreeFilterValue);

XMLPORT.EXPORT(OutboundPort,OutS,??TableRef.GETTABLE(TableNo)??);

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    I'm afraid you have to use a CASE structure, and declare x-number of rec-variables based on RecRef.NUMBER.
    CASE RecRef.NUMBER OF
      DATABASE::Item: XMLPORT.EXPORT(OutboundPort,OutS,recItem);
      DATABASE::Customer: XMLPORT.EXPORT(OutboundPort,OutS,recCustomer);
    ...
    END;
    
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • kinekine Member Posts: 12,562
    Or you can base the XMLPOrt on Integer table and pass the RecRef as parameter of some function. Than call the XMLPort throug variable of type XMLPort... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • nismo2006nismo2006 Member Posts: 22
    Worked great! I appreciate the help and have a good day.
Sign In or Register to comment.