export Nav. object programmatically

charles.rooscharles.roos Member Posts: 60
Hi,
Can i programmatically export Navision object?

The functionality should open File-Save dialog and ask for exported file name, and then export the object to the local hard drive, all this should be done programmatically, ala:

Nav.OpenExportDialog(objID, '*.txt');
FileName := nav.GetExportedObjectFilePath;
//read file in location "FileName"

Or if possible then File-Save dialog shouldn't be shown at all if possible.

The solution would be a form with a button and if user presses the button the exporting would be done.

Can such functionality be done at all?

Comments

  • garakgarak Member Posts: 3,263
    only with WSH and Sendkeys. But the user must have permissions to open the object designer.

    Take a look here. It's the same princip
    Do you make it right, it works too!
  • kinekine Member Posts: 12,562
    In NAV 5.00SP1 you can use the ExportFOB and ImportFOB from C/Fornt for that. And you can use the C/Front inside NAV... :-) but just only as FOB...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • charles.rooscharles.roos Member Posts: 60
    Thx for your relpies.
    I see that one should use this object to create programmatical key presses in Navision client:
    "Windows Script Host Object Model.WshShell"

    This should solve what i need, thx you both.
  • krikikriki Member, Moderator Posts: 9,112
    You can also export the BLOB in the object-table to a file. In another DB, you can import them in the same way. But you need to maintain the values of the fields (ID,Name,Version-list,date,time) in the object-table yourself.
    If you export it in this way, you CANNOT import the object with the File=>Import-function. I did something like this in 3.01 with the NAS for replicating objects from 1 DB to another.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • PureHeartPureHeart Member Posts: 190
    kine wrote:
    In NAV 5.00SP1 you can use the ExportFOB and ImportFOB from C/Fornt for that. And you can use the C/Front inside NAV... :-) but just only as FOB...
    Hi,

    I've build a wrapper dll for the Cfrontdotnet....it works fine calling it from NAV but when I give the command to CloseDatabase(), NAV crashes....if I comment the closedatabase the dll doesn't give the error but when I close NAV then again NAV crashes.....

    ANY idea why this is happening???????????????? ](*,) ](*,) ](*,) ](*,) ](*,) ](*,)
    Why don't you try my compare tool?
    http://www.mibuso.com/dlinfo.asp?FileID=1123
  • PureHeartPureHeart Member Posts: 190
    Noone has tried to do this? ](*,) ](*,)
    Why don't you try my compare tool?
    http://www.mibuso.com/dlinfo.asp?FileID=1123
  • ssinglassingla Member Posts: 2,973
    Isn't this what you are looking for?

    http://www.codeproject.com/KB/library/AutoupateNAV.aspx?display=Print

    The only difference it seems that it is in C#.
    CA Sandeep Singla
    http://ssdynamics.co.in
  • PureHeartPureHeart Member Posts: 190
    Thanks but that can only export/import as txt (which the tool in my signature is doing...) not as FOB which is why I'm using C/FRONT...
    What I've done is I've built a DLL in C# that I'm calling from NAV to Export objects as fob files....
    it works fine but sometimes it crashes NAV...and I discovered that crashes NAV when I close the database with CloseDatabase();

    This is the code:
     public bool ExportFob(string NAV_path,string servername,string databasename,string export_fob_filename_path,string export_filters,ref string error_msg)
            {            
                CFrontDotNet.DriverType = NavisionDriverType.Sql;
                CFrontDotNet.NavisionPath = NAV_path;            
                CFrontDotNet.HideErrors = true;
    
                CFrontDotNet nav_instance = new CFrontDotNet();
                
                try
                {
                    nav_instance.ConnectServerAndOpenDatabase(servername, NavisionNetType.SqlDefault, databasename,        2000,false, true, "", "");
    
    
                    nav_instance.ExportFOB(@export_fob_filename_path, export_filters);
    
    
    [color=#FF0000]                This line crashes NAV if I comment it works fine but then NAV crashes when I close NAV itself[/color]
                    //nav_instance.CloseDatabase();
    
    
                    return true;
                }
                catch (Exception e)
                {
                    error_msg = e.Message;
                    return false;
                }
            }
    
        }
    

    Anyone??? Anyone???
    Why don't you try my compare tool?
    http://www.mibuso.com/dlinfo.asp?FileID=1123
  • PureHeartPureHeart Member Posts: 190
    Am I the Only ONE?
    Why don't you try my compare tool?
    http://www.mibuso.com/dlinfo.asp?FileID=1123
  • prakash5315prakash5315 Member Posts: 2
    kine wrote:
    In NAV 5.00SP1 you can use the ExportFOB and ImportFOB from C/Fornt for that. And you can use the C/Front inside NAV... :-) but just only as FOB...

    I was trying to use importfob and exportfob from cfront in nav2009r2, by following the example https://msdn.microsoft.com/en-in/library/dd338953.aspx, this example is working fine, but while using importfob function in cfront, i am getting the below error for the respective codes

    1)
    cfront.importfob(vartext,1); //vartext is the file location 'C:\test.fob'

    "This data type is not supported by C/SIDE. You can access data from
    any of the following data types:

    VT_VOID, VT_I2, VT_I4, VT_R4, VT_R8, VT_CY, VT_DATE, VT_BSTR and VT_BOOL"

    2)
    cfront.importfob(varVariant,1); //varVariant is the file location 'C:\test.fob'

    This message is for C/AL programmers:

    Type conversion of Text is not possible.
    VT_LPWSTR was probably the target type.

    I can see that problem is with finding LPWSTR equivalent datatype in nav, same is in exportfob too.

    Any idea about this error?
    Thanks in advance.
  • FOB file is not compiled. To import fob using C/Side, we should have compiled FOB
Sign In or Register to comment.