Automatic creation of fob file in C/AL

Hello, I must create a fob file for an object, several time. I created a Report with table OBJECT : onaftergetrecord() CASE Object.Type OF Object.Type::TableData:txtObjectType:=‘TableData’; Object.Type::Table:txtObjectType:=‘Table’; Object.Type::Form:txtObjectType:=‘Form’; Object.Type::Report:txtObjectType:=‘Report’; Object.Type::Dataport:txtObjectType:=‘Dataport’; Object.Type::Codeunit:txtObjectType:=‘Codeunit’; Object.Type::System:txtObjectType:=‘System’; Object.Type::FieldNumber:txtObjectType:=‘FielNumber’; END; txtpath := txtpath + txtObjectType + ‘_’ + FORMAT(Object.ID) + ’ ’ + Object.Name + ‘.fob’; Object.CALCFIELDS(Object.“BLOB Reference”); Object.“BLOB Reference”.EXPORT(txtpath,FALSE); But the file created is empty… help me, thank you.

Benoît, A little more information would help us in helping you. What variables have you created and what are their data types & lengths?! What version are you running? Navision Financials 1.30, 2.00, 2.01, 2.50, 2.60 or Navision Attain 3.01, 3.10 or Microsoft Navision Version 3.60? Have you tried debugging your code?

Hi! Maybe this will do it: Object OnAfterGetRecord() // I suppose your Dataitem is "Object" CLEAR(filename); // I suppose "txtpath" is something like "c:\temp" CASE Object.Type OF Object.Type::TableData: txtObjectType := 'TableData'; Object.Type::Table: txtObjectType := 'Table'; Object.Type::Form: txtObjectType := 'Form'; Object.Type::Report: txtObjectType := 'Report'; Object.Type::Dataport: txtObjectType := 'Dataport'; Object.Type::Codeunit: txtObjectType := 'Codeunit'; Object.Type::System: txtObjectType := 'System'; Object.Type::FieldNumber: txtObjectType := 'FielNumber'; END; filename := STRSUBSTNO('%1\%2_%3_%4.fob',txtpath, txtObjectType, FORMAT(Object.ID), Object.Name); Object.CALCFIELDS("BLOB Reference"); IF Object."BLOB Reference".HASVALUE THEN BEGIN Object."BLOB Reference".EXPORT(filename,FALSE); YIELD; END; Regards, Jörg

Thank you for your answers, I work under version 2.10. I will like to export objects by creating files with the format text. Benoît

Jörg, have you been able to import a file created with your code? In Attain 3.60 it is not possible, and a quick comparison shows a lot of differences between a original fob and a fob created by this code.

Alex, if you EXPORT the BLOB-Reference by code, then you have to IMPORT it the same way, e.g. Object.GET(<Type>,<Company>,<ID>); Object."BLOB Reference".IMPORT(<Filename>, FALSE); Object.MODIFY; So, the extension .FOB is in fact not correct! I prefer to use .BIN (Binary). This works pretty good, also in 3.60. Regards, Jörg

Thanks, I thought you were trying to create a real fob.