Options

How to open a file from Page in Role Tailored Client?

postsauravpostsaurav Member Posts: 708
edited 2011-12-27 in NAV Three Tier
Hi all,

i am facing a wired problem.

I have customized a form where you can open, import, export and remove documents. Its working fine in classic.

All other functions except OPEN works fine in RTC.
When i try to use OPEN Function it on Role Tailored client first it gave me warning - "Function 'ENVIRON' is obsolete for Microsoft Dynamics NAV Server."

I used this function in the code where i want to get the File Name. Please let me know what function can be used to open a document from code whose file name , path and extension are stored in the database.

Thanks & Regards,
Saurav Dhyani

Thanks & Regards,
Saurav Dhyani

Do you Know this About NAV?


Connect - Twitter | Facebook | Google + | YouTube

Follow - Blog | Facebook Page | Google + Page

Answers

  • Options
    mohana_cse06mohana_cse06 Member Posts: 5,503
  • Options
    postsauravpostsaurav Member Posts: 708
    Hi mohan,

    I have used the same, but what happens is a dialoug window get opened.
    what i want is that when i click on that option the file get open directly without saving.

    Thanks & Regards,
    Saurav Dhyani

    Thanks & Regards,
    Saurav Dhyani

    Do you Know this About NAV?


    Connect - Twitter | Facebook | Google + | YouTube

    Follow - Blog | Facebook Page | Google + Page
  • Options
    mohana_cse06mohana_cse06 Member Posts: 5,503
    Can you show your code or send me through PM
  • Options
    postsauravpostsaurav Member Posts: 708
    Dear Mohan,

    For set File Name i use this -

    FileName := ENVIRON('TEMP') + Text012 + DocNo + '.' + "File Extension";

    where -
    1) Filename - Text type of variable.
    2) Text012 -Text Constant whose value is \Doc
    3) DocNo - 39.
    4) File Extension - A variable which stores file extension type.

    Please let me know how i can use this code in RTC.

    Thanks & Regards,
    Saurav Dhyani

    Thanks & Regards,
    Saurav Dhyani

    Do you Know this About NAV?


    Connect - Twitter | Facebook | Google + | YouTube

    Follow - Blog | Facebook Page | Google + Page
  • Options
    mohana_cse06mohana_cse06 Member Posts: 5,503
    I tried with below code and got temp file names path in both classic and RTC

    DocNo := '1';
    "File Extension" := '.txt';
    IF NOT ISSERVICETIER THEN
    FileName := ENVIRON('TEMP') + Text012 + DocNo + '.' + "File Extension"
    ELSE
    FileName := "3-Tier".EnvironFileName('',"File Extension");

    MESSAGE('%1',FileName);
  • Options
    postsauravpostsaurav Member Posts: 708
    Hi mohan,

    yeah that is write, i checked at the location and the file is actually getting saved there. But its not getting open.

    For opening file what i have used this function which is working fine in classic -

    IF NOT EXISTS(FilePathName) THEN
    ERROR(Text001);
    IF NOT SplitFilePathName(FilePathName,FolderName,FileName) THEN
    ERROR(Text002);

    CREATE(objShell);

    objFolder := objShell.NameSpace(FolderName);
    objFolderItems := objFolder.Items;
    objFolderItem := objFolderItems.Item(FileName);
    objFolderVerbs := objFolderItem.Verbs;
    i := -1;
    REPEAT
    i := i + 1;
    IF i < objFolderVerbs.Count THEN
    objFolderVerb := objFolderVerbs.Item(i);
    UNTIL (STRPOS(UPPERCASE(objFolderVerb.Name),Text006) > 0) OR (i >= objFolderVerbs.Count);

    IF (STRPOS(UPPERCASE(objFolderVerb.Name),Text006) > 0) THEN
    objFolderVerb.DoIt
    ELSE
    ERROR(Text004,FileName);

    Where SplitFilePathName is used to break the path of the file name into folders name and file name.
    objShell 'Microsoft Shell Controls And Automation'.Shell
    objFolder 'Microsoft Shell Controls And Automation'.Folder
    objFolderItems 'Microsoft Shell Controls And Automation'.FolderItems
    objFolderItem 'Microsoft Shell Controls And Automation'.FolderItem
    objFolderVerbs 'Microsoft Shell Controls And Automation'.FolderItemVerbs
    objFolderVerb 'Microsoft Shell Controls And Automation'.FolderItemVerb

    how it can be taken into RTC, or if there is any default function to open file from RTC.

    Thanks & Regards,
    Saurav Dhyani

    Do you Know this About NAV?


    Connect - Twitter | Facebook | Google + | YouTube

    Follow - Blog | Facebook Page | Google + Page
  • Options
    SogSog Member Posts: 1,023
    You can use codeunit "3-tier management" for handling files on the client as well on the server.
    But first, make a distinct difference of files residing on the cliënt and files residing on the server.
    Shell is of no need, hyperlink usually works.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • Options
    postsauravpostsaurav Member Posts: 708
    Hi sog,

    File get downloaded on the client not at server.
    Please let me know how can i open the file without using shell & what is hyperlink ?

    Thanks & Regards,
    Saurav Dhyani

    Thanks & Regards,
    Saurav Dhyani

    Do you Know this About NAV?


    Connect - Twitter | Facebook | Google + | YouTube

    Follow - Blog | Facebook Page | Google + Page
  • Options
    mohana_cse06mohana_cse06 Member Posts: 5,503
    Just wanted add a point here..

    If you say OPEN('C:\temp.txt');

    Classic client search for the file in Client system but RTC search it in the system where servicetier is installed.
    so you have to UPLOAD your file to servicetier system and open it..
  • Options
    Troubles_In_ParadiseTroubles_In_Paradise Member Posts: 588
    postsaurav wrote:
    ..
    & what is hyperlink ?
    Sog refers to Hyperlink standard function, check it in the online help.
    Try to pass to this function the URL of the file you want to open.
    ~Rik~
    It works as expected... More or Less...
Sign In or Register to comment.