mibuso.com

Microsoft Business Solutions online community
It is currently Thu Oct 23, 2014 9:11 pm

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: DOWNLOAD function
PostPosted: Thu Jun 14, 2012 5:19 pm 
Offline

Joined: Mon May 28, 2007 10:23 am
Posts: 110
Location: Italy
I have this code:

IF NOT DOWNLOAD(FileName,'','c:\Temp','',ToFileName) THEN
ERROR('Error..');

Why Nav ask me save or open with dialog window?
How I can to skip and save it without ask me before?


Top
 Profile  
 
 Post subject: Re: DOWNLOAD function
PostPosted: Thu Jun 14, 2012 6:34 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Tue Sep 02, 2008 8:37 am
Posts: 4602
Location: Hyderabad
Country: India (in)
Check whether this link can help you
http://mibuso.com/blogs/mohana/2011/02/20/file-export-in-rtc-with-%e2%80%9ccommon-dialog-management%e2%80%9d/

_________________
-Mohana
http://mibuso.com/blogs/mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav


Top
 Profile  
 
 Post subject: Re: DOWNLOAD function
PostPosted: Thu Jun 14, 2012 8:24 pm 
Offline

Joined: Mon May 28, 2007 10:23 am
Posts: 110
Location: Italy
But my problem is that I DON'T want common dialog...


Top
 Profile  
 
 Post subject: Re: DOWNLOAD function
PostPosted: Fri Jun 15, 2012 6:13 am 
Offline
MVP Microsoft Dynamics NAV

Joined: Tue Sep 02, 2008 8:37 am
Posts: 4602
Location: Hyderabad
Country: India (in)
Then simply skip that part and give fixed path in FileName2..

_________________
-Mohana
http://mibuso.com/blogs/mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav


Top
 Profile  
 
 Post subject: Re: DOWNLOAD function
PostPosted: Fri Jun 15, 2012 7:53 am 
Offline

Joined: Fri Nov 13, 2009 3:04 pm
Posts: 76
Location: Barcelona
Country: Spain (es)
You should you functions of the CU 419. There is one that can help you to solve the problem - "Magicpath"
Code: Select all
Magicpath() : Text[1024]
EXIT('<TEMP>');   // MAGIC PATH makes sure we don't get a prompt
The description says it all. Than you can handle with your file as you want (move it/copy it etc.)


Top
 Profile E-mail  
 
 Post subject: Re: DOWNLOAD function
PostPosted: Mon Jun 18, 2012 3:26 pm 
Offline

Joined: Mon May 28, 2007 10:23 am
Posts: 110
Location: Italy
koubek, can you write sample?

This is my code:

IF NOT DOWNLOAD(FileName,'','h:','',ToFileName) THEN
ERROR('No');

Where:
Filename (string) = RBMgt.EnvironFileName('','txt');
ToFileName (string) = 'H:\Test.txt'


Top
 Profile  
 
 Post subject: Re: DOWNLOAD function
PostPosted: Mon Jun 18, 2012 10:57 pm 
Offline

Joined: Fri Nov 13, 2009 3:04 pm
Posts: 76
Location: Barcelona
Country: Spain (es)
This is a simple demonstration. Focuse on the function "RunDemo()".
Code: Select all
OBJECT Page 50009 Download File Demo
{
  OBJECT-PROPERTIES
  {
    Date=18/06/12;
    Time=22:53:37;
    Modified=Yes;
    Version List=JVN,FILE,DOWNLOAD;
  }
  PROPERTIES
  {
    CaptionML=ENU=Download File Demo;
    SaveValues=Yes;
    OnOpenPage=BEGIN
                 IF (SrcFileName = '') THEN
                   SrcFileName := 'C:\Temp\MySourceFile.txt';

                 IF (DestFileName = '') THEN
                   DestFileName := 'C:\Temp\MyDestinationFile.txt';
               END;

    ActionList=ACTIONS
    {
      { 1100225000;  ;ActionContainer;
                      CaptionML=ENU=Demo;
                      ActionContainerType=NewDocumentItems }
      { 1100225001;1 ;Action    ;
                      Name=<Action1100225001>;
                      CaptionML=ENU=Run Demo;
                      Promoted=Yes;
                      PromotedIsBig=Yes;
                      PromotedCategory=Process;
                      OnAction=BEGIN
                                 RunDemo;
                               END;
                                }
    }
  }
  CONTROLS
  {
    { 1100225002;;Container;
                CaptionML=ENU=Download Demo Data;
                ContainerType=ContentArea }

    { 1100225005;1;Group  ;
                CaptionML=ENU=File Names;
                GroupType=Group }

    { 1100225003;2;Field  ;
                CaptionML=ENU=Source File;
                SourceExpr=SrcFileName }

    { 1100225004;2;Field  ;
                CaptionML=ENU=Target File;
                SourceExpr=DestFileName }

  }
  CODE
  {
    VAR
      FileMgt@1100225002 : Codeunit 419;
      SrcFileName@1100225000 : Text[1024];
      DestFileName@1100225001 : Text[1024];
      Text001@1100225003 : TextConst 'ENU=You have not define any of parameters!';
      Text002@1100225004 : TextConst 'ENU=The file has been downloaded';
      Text003@1100225005 : TextConst 'ENU=Destionation file already exists! Delete it first!';

    PROCEDURE RunDemo@1100225001();
    VAR
      LocalTempFile@1100225000 : Text[1024];
    BEGIN
      IF (SrcFileName = '') OR (DestFileName = '') THEN
        ERROR(Text001);

      IF (EXISTS(DestFileName)) THEN
        ERROR(Text003);

      LocalTempFile := FileMgt.DownloadTempFile(SrcFileName);
      RENAME(LocalTempFile,DestFileName);

      IF GUIALLOWED THEN
        MESSAGE(Text002);
    END;

    BEGIN
    END.
  }
}


Top
 Profile E-mail  
 
 Post subject: Re: DOWNLOAD function
PostPosted: Fri Jun 22, 2012 4:43 pm 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2014 attendee

Joined: Mon Apr 04, 2005 3:49 pm
Posts: 251
Location: Sauðárkrókur
Country: Iceland (is)
Hi Koubek

You will have to use a client base RENAME function. The one in your example is server based.

I use the automation object "'Windows Script Host Object Model'.FileSystemObject"

A codeunit with the automation based filesystem function can be downloaded from my blog http://www.dynamics.is/?p=218

_________________
________________________________
Gunnar Gestsson
Microsoft Certified IT Professional
Dynamics NAV MVP
http://www.dynamics.is
http://Objects4NAV.com


Top
 Profile E-mail WWW  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: Google [Bot], PrebenRasmussen and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: