Create Export FOB from a Codeunit

This is actually a two part question.

Part 1: Is it possible to create an export fob from a codeunit?

Part 2: Can you read fob to identify which objects are contained in it?

The end result would be a codeunit that I run when I’m about to import a fob to the live system. The codeunit would read the incoming fob, identify which objects would be changed by the fob, then create an export FOB of all those objects.

Apparently there is a way to export a FOB from within Code, although I don’t think it is that stable. I think you can find a free DLL or something similar on MIBUSO. A colleague of mine has used this but I think it crashes NAV after exporting (probably not what you are after [;)])

If you are using NAV 2009 SP1 you can export the objects as Text from within code and if your intention is to keep a copy of objects before overwriting them, then this would be a good solution and does not require third party/unstable components. You can also read a FOB file as the first few bytes are a Text listing of the contents of the FOB. There are a few examples of add-ons that use this to show you the contents of the FOB file - again I’ve downloaded these in the past from MIBUSO.

Practically, you can’t beat having good working practices. Maybe you should just train your users that before they import FOB files to a production system, they export all objects as a FOB. This doesn’t take too long to run and is quicker than going through and manually selecting the objects to export. It is very rare anyone will ever need to restore from this FOB but atleast, you will have a copy of everything as it was before you did the import so you can select only the objects you want to recover.

I did a quick search in MIBUSO downloads and found this which sounds like what you are looking for.

I think I also found the dll on this post



Although the DLL is free, it is a plug in for Beyond Compare, a program that I do not have. Though it does sound like what I am looking for.

We are currently using NAV 5.0 SP1, but I hear we will be upgrading to 2009 in the next few months, so maybe I will revisit this then.

In the meantime I will have a look for other posts that tell of how to read the FOB file and mark the objects, then I will do the Export manually.

Thanks for your help.