So, just to summarize … you have a custom table that includes the field "No. Equipamento” and this field is related to the “No.” field in the Item table. Now you’re writing a report on the custom table and you need to include some data from the Item table.
In your report, in the OnAfterGetRecord trigger of your custom table, you’ll need to retrieve the Item record that’s related to the value in “No. Equipamento”. Once you have the right Item record in current memory, you have access to all of the fields in the table and you can pretty much do whatever you want with it.
There are a couple of ways to go about finding the matching Item record. You can use the FILTER/FIND method like you’ve already been discussing, or you can use the GET method. In this case, I’d prefer the GET method because it’s less complicated to code, it returns the Item record far more quickly (the “No.” field is the primary key for the Item record), and you don’t have to write any special error-handling code if you don’t want to. You would simply type one single command:
and that’s it. If you really want to get fancy, you can add code to trap for possible errors, like the case where “No. Equipamento” is blank…
if “No. Equipamento” <> ‘’ then
or the case where you have an invalid value in "No. Equipamento”…
if not Item.GET(“No. Equipamento”) then
… raise an error, or
… call Item.INIT to blank the record and continue on
In either case, it’s definitely quicker, and much easier than trying to remember to return the Item record to its previous condition (filters, current record, etc.)
Once you have the right Item record in current memory, you can display any of the field values on the report by creating text boxes and using Item.“Description” or any other Item field as the source expression.
That should solve your problem.
Oh, and one other observation, if you don’t mind? I haven’t been at this for too terribly long, but I have come to understand that the community frowns most strenuously on the use of Hungarian naming conventions or anything that remotely resembles it. So, rather than naming your variable RecItem, just call it Item. There’s a document out there that covers nothing but naming conventions. It’s a great resource. And if you get stuck, just search the standard Navision code to see how the original developers name objects. You will see variations here too, but you’ll at least be able to see what the standard looks like.
I hope that helps. Sorry that it’s so long.