Runtime Error when RecordRef trying to get missing RecordID

sunmorningindiasunmorningindia Member Posts: 65
1.Create a Table like:
Field No. Field Name Data Type
1 Entry No. Integer
2 Rec ID RecordID
2.Add the following values:
Entry No. Rec ID
1 Table20000
Note: Table 20000 not exists.
3.Create a Codeunit and add the following code on OnRun() trigger :
TestRecordID.GET(1);
IF RecRef.GET(TestRecordID."Rec ID") THEN
MESSAGE('Pass')
ELSE
MESSAGE('Fail');

Output :
TableData 20000 does not exist.
Expected:
Fail

I put this example for an open discussion.
Post your valuable suggestion.

Comments

  • vaprogvaprog Member Posts: 1,139
    • Your RecordID is not valid, the primary key value is missing. I wonder why NAV accepts it. This, however, does not take any effect on the issue brought before the community. I mention this here because, if you do try to add a primary key value in order to create a fully specified RecordID, nav gives an error on editing or EVALUATEing the RecordID. If the RecordID was valid once, with the primary key beeing blank, then the table was deleted or renumbered, NAV does not show the primary key value, just as in your example.
    • I agree. I would expect the same result as you do. Moreover there is no easy way to overcome this. You probably will have to search one of the Object virtual tables for the table or TableData with RecID.NUMBER as it's object number where RecID is a variable set to the value of TestRecordID."Rec ID"
    So: quite some peculiar "features" here...
Sign In or Register to comment.