I have to initiate the import of an object (a .fob or .txt file) automatically from the trigger of an event in Navision, but even though I searched a few days for some way to do it, I couldn’t find a thing…
Hi Shaidallar ! I think you should keep it simple - like this: Create two Dataports - one for import, one for export (set the “Import” property of you Dataports in the corresponding way), specify file names for them (the “File Name” property), probably, you should set the “AutoReplace” property of your DataItem to “Yes” to avoid those bored messages like “The record already exists”. Now, the only thing you need is to insert
quote:
DATAPORT.RUNMODAL(DATAPORT::“Your Dataport”,FALSE);
wherever you need it ! Go ahead - Export and Import. If you want the Request window to be displayed - just set the second parameter to “TRUE”. But, I have another question about this. Why dont the following functions work:
quote:
DMCDataport.FILENAME := ‘D:\dmc.txt’; DMCDataport.IMPORT := FALSE; DMCDataport.RUNMODAL;
When the request form opens - it contains neither “File Name” = ‘D:\dmc.txt’ nor Direction = Export !!! Best regards, DMC
Hey Ulises Sasovsky ! Sorry ! It seems like I misunderstood your question - you are talking about *.fob and *.txt !!! And my answer about Importing and Exporting data ! Sorry, I have no answer to your question… yet! But still - does anybody knows WHY THOSE FUNCTIONS DONT WORK ??? DMC
To my knowledge, there is no way to programmatically import an object. According to the feedback I got to that question from Navision support several months ago, the only way to import an object is manually. If someone knows differently, I would appreciate their input. Dave Studebaker das@libertyforever.com Liberty Grove Software A Navision Services Partner
Thank you all for your replies! If someone does find out how to do it, please let me know.
This is how it works: For W1-Version (the field names vary for the different language versions) //Exporting Obj.SETRANGE(Type,Obj.Type::Table); //choose a single object to export Obj.SETRANGE(ID,18); IF Obj.FIND(’-’) THEN BEGIN //“BLOB Reference” is a flowfield so it has to be calculated first Obj.CALCFIELDS(“BLOB Reference”); Obj.“BLOB Reference”.EXPORT(‘f:\fileexport.fob’,FALSE); END; //Importing Obj.Type := Obj.Type::Table; Obj.ID := 70100; Obj.Name := ‘My imported Object’; Obj.Compiled := TRUE; Obj.Date := TODAY; Obj.Time := TIME; Obj."BLOB Reference.IMPORT(‘f:\fileexport.fob’,FALSE); // If available, overwrite IF NOT Obj.INSERT THEN Obj.MODIFY; // ********************************* For DE-Version: //Exporting Obj.SETRANGE(Typ,Obj.Typ::Table); Obj.SETRANGE(ID,18); IF Obj.FIND(’-’) THEN BEGIN //“BLOB Reference” is a flowfield so it has to be calculated first Obj.CALCFIELDS(“BLOB Referenz”); Obj.“BLOB Referenz”.EXPORT(‘f:\fileexport.fob’,FALSE); END; //Importing Obj.Typ := Obj.Typ::Table; Obj.ID := 70100; Obj.Name := ‘My imported Object’; Obj.Kompiliert := TRUE; Obj.Datum := TODAY; Obj.Zeit := TIME; Obj.“BLOB Referenz”.IMPORT(‘f:\fileexport.fob’,FALSE); // If available, overwrite IF NOT Obj.INSERT THEN Obj.MODIFY; The exported file is no complete fob file because the header is missing. Therefore this file can’t be imported using the normal FILE->Import->Import Worksheet function. Hope this helps. Bye, Torsten
Hmm … when I export an object this way, and then try to import it again via “Object Designer” and “Import”, an Error occurs:
quote:
Es gibt einen Syntaxfehler in der Einlesung auf Zeile 1 , Position 0: 1/4 4. Hier sollte ein neues Objekt beginnen.
(Syntaxerror at line 1, position 0: 1/4 4. A new object should begin here.) What’s wrong? We are running NF DE2.60.D … As far as I remember, this worked a time ago (maybe on NF DE2.01 ?) … I also always thought, it’s possible to export/import objects as Textfiles this way … Confused, Jörg Joerg A. Stryk Apollo-Optik, IT/ERP
Ha! 10 minutes and a few tests later … When I export an object by code (Object."BLOB Reference.EXPORT) i have to import them by code (Object."BLOB Reference.IMPORT) So, it’s maybe confusing to export the objects as FOB or TXT, better would be an suffix like BIN (binary). Are there any ways to create real FOBs or TXTs? Best Regards, Jörg Joerg A. Stryk Apollo-Optik, IT/ERP
As far as I know, C/FRONT can import/export objects Lars Strøm Valsted ------------------------- Why can’t programmers tell the difference between Christmas and Halloween? Because OCT(31) = DEC(25)
Hi Jörg, if you’d ve read the last paragraph of my posting you would’t have had to spend 10 minutes No, so far there is no direkt C/SIDE related possibility to create real fobs. I compared the direct output object to the real fob and they are equal despite the header. So you can start investigating the header and create your “real” fobs Torsten
quote:
Originally posted by stryk: Ha! 10 minutes and a few tests later … When I export an object by code (Object."BLOB Reference.EXPORT) i have to import them by code (Object.“BLOB Reference.IMPORT) [img]/forum/images/icon_smile_big.gif” border=“0”> So, it’s maybe confusing to export the objects as FOB or TXT, better would be an suffix like BIN (binary). Are there any ways to create real FOBs or TXTs? Best Regards, Jörg Joerg A. Stryk Apollo-Optik, IT/ERP
Edited by - todro on 2002 Aug 14 10:14:25