How can I get the RecordID of a Record?

crisnicolascrisnicolas Member Posts: 177
I need to get the RecordID of a Record, but I haven't found the correct function to do that.

I have only found this function:
RECORDID (RecordRef)
Use this function to return the RecordID of the record that is currently selected in the table. If no table is selected, an error is generated.

RecordID := RecordRef.RECORDID

But I do not have a RecordRef, I have a Record.

Thanks for your help

Answers

  • jlandeenjlandeen Member Posts: 524
    You can turn any record variable into a record ref by using the gettable/settable functions of a record ref variable.

    What are you trying to accomplish in code?
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • crisnicolascrisnicolas Member Posts: 177
    I'm trying to get the recordlinks of a record.
  • crisnicolascrisnicolas Member Posts: 177
    I've tried this, but it is not working:
    IF PurchaseHeader.HASLINKS THEN
    BEGIN
      RecRef.OPEN(DATABASE::"Purchase Header");
      RecRef.SETTABLE(PurchaseHeader);
      PurchHeaderRecordID := RecRef.RECORDID;
      RecordLink.SETRANGE(RecordLink."Record ID",PurchHeaderRecordID);
      IF RecordLink.FINDSET THEN
      REPEAT
        MESSAGE(RecordLink.URL1);
      UNTIL RecordLink.NEXT = 0;
    END;
    

    The SETTABLE function does not make RecRef to be positioned on the record PurchaseHeader was.... RecRef has the default values (Order,'')
  • jlandeenjlandeen Member Posts: 524
    have you tried GetTable instead of settable?
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • jlandeenjlandeen Member Posts: 524
    have you tried GetTable instead of settable?
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • crisnicolascrisnicolas Member Posts: 177
    ooppps... yeah, that was it! thanks!
  • jlandeenjlandeen Member Posts: 524
    Yeah I don't think the documentation on those functions is adequate. It's similar to the Get & Set property functions they had in the old VB6 days, but in reverse. GetTable gets the values from the record and puts them in the record ref, while the SetTable pushes them back to the Record variable.
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
Sign In or Register to comment.