Launching Applications of files from the RT Client in 2009

bmccarthybmccarthy Member Posts: 48
edited 2009-12-11 in NAV Three Tier
Hi,
we are looking at updating our NAV addin for NAV2009. Part of our integration allows you to use NAV to view files stored outside of NAV. A text file for example stored in a shared network folder. From the classic client we use a custom COM automation component to launch the correct application to view files when requested by the user. This does not work in the RT client as the COM component is running on the server and not client side.

So, is there any way to launch an application client side from the Role tailored client. I see that the links dialog does this but we cannot access the code in that page as it is hidden..

Anyone got any ideas???

Oh ya, SHELL is obsolete for the RT client so that doesn't work. :cry:
B

Comments

  • DenSterDenSter Member Posts: 8,307
    Can you use recordlinks, which is standard in NAV2009?
  • ara3nara3n Member Posts: 9,256
    You can use windows script host DLL and instantiate it on the client to run the code.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • bmccarthybmccarthy Member Posts: 48
    Nice one, works well thanks!! :D

    Here is some sample code for anyone wondering:

    Locals:
    Name DataType Subtype Length
    Vbs OCX ScriptControl Object
    code1 Text 250
    txtCR Text 30
            Vbs.Language := 'VBScript';
    
            txtCR := '';
            txtCR[1] := 13;
    
            code1 := code1 + 'sub OpenFile()' + txtCR;
            code1 := code1 + 'dim objShell' + txtCR;
            code1 := code1 + 'Set objShell = CreateObject("Shell.Application")' + txtCR;
            code1 := code1 + STRSUBSTNO('objShell.Open("%1")',  filePath) + txtCR;
            code1 := code1 + 'set objShell = Nothing' + txtCR;
            code1 := code1 + 'End Sub'+ txtCR;
    
            Vbs.AddCode(code1);
            Vbs.ExecuteStatement('OpenFile()'+ txtCR );
    
  • krikikriki Member, Moderator Posts: 9,115
    [Changed the attribute of the topic to <Solved>/<Good Posting>]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • bmccarthybmccarthy Member Posts: 48
    Ok, so I've made progress with the file opening but I already have functions like this in a COM dll which I call from the classic client on the client side via automation. I would like to run other functions in my COM dll on the client machine such as printing the file and launching a scanner interface. To do so I have written and OCX (like the ScriptControl Object) to call from the Role Tailored PAGE which will in turn call my registered COM component. Is this going to work? Or is the ScriptControl a special OCX? Is this a viable solution for re-routing calls to my automation objects which are not available in pages as automation functions run on the server or is there a standard method for performing local client operations from pages?

    So far I have registered my OCX however I can't see my OCX functions. Has anyone ever written a custom OCX to call function on from NAV? If so any tips on getting NAV to see the functions?

    Cheers
  • ara3nara3n Member Posts: 9,256
    I don't think you can use ocx for RT client. It needs to be activeX/COM dll file
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • ara3nara3n Member Posts: 9,256
    you can't use CREATE for ocx components.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • stomdahlstomdahl Member, Microsoft Employee Posts: 12
    Creating an variable of type OCX will instantiate it to run on the machine that runs the client, this is also valid for RTC.
    If you wish to create an automation object that is goind to run on the client machine, you must use the method that takes tree arguments. Where the last argument determines where the automaiton object will be created. True = Client and False = Server.

    Create(someAutomationVariable,True/False(New Server),True/False (Run on Client));
  • ara3nara3n Member Posts: 9,256
    stomdahl wrote:
    Creating an variable of type OCX will instantiate it to run on the machine that runs the client, this is also valid for RTC.
    If you wish to create an automation object that is goind to run on the client machine, you must use the method that takes tree arguments. Where the last argument determines where the automaiton object will be created. True = Client and False = Server.

    Create(someAutomationVariable,True/False(New Server),True/False (Run on Client));



    From you example above it's automation variable not OCX!!!!!
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • freddy.dkfreddy.dk Member, Microsoft Employee Posts: 360
    Correct

    Automation variables can be instantiated on the Client Tier with the CREATE statement, setting the third paramter to TRUE.
    OCX'es will demand load on the Client Tier always (there is an implicit CREATE done the first time you use the variable of type OCX)

    You only need to install the Automation object (DLL) or the OCX on the tier on which they will run - but note, that when you import .fob's and when you enable the NAV Server and other things - we need to compile all objects and during this compile process - the automation objects and the OCX'es needs to be present to do a successful compile.

    If the objects are not present, compile will fail and you will have to go to a machine which has the object to do the compile.

    /Freddy
    Freddy Kristiansen
    Group Program Manager, Client
    Microsoft Dynamics NAV
    http://blogs.msdn.com/freddyk

    The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.
  • ara3nara3n Member Posts: 9,256
    Thanks for the clarification. I have to try it. Maybe add this info to the help file?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • bmccarthybmccarthy Member Posts: 48
    I thought the main message of the Role Tailored Client was that you will not be able to run your Automation objects client side and hence why I started this thread...

    If all it takes is an extra undocumented parameter then I've been merrily wasting my time writing an OCX. Perhaps Microsoft should have considered this before telling everyone to refactor their code to run Automation server side. :x
    B
  • kinekine Member Posts: 12,562
    It is not so simple. Do not forget to the limitations for the automation which cna be run on client side or on server side.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • freddy.dkfreddy.dk Member, Microsoft Employee Posts: 360
    I thought the main message of the Role Tailored Client was that you will not be able to run your Automation objects client side and hence why I started this thread...
    Originally this was a limitation in NAV 2009 - but one of the thing we learned by having the TAP program with NAV 2009 was that this wasn't going to fly. As kine mentions there are limitations to what automation objects can do in 2009, but there are ways around a number of the limitations (not all). I will try to describe some of these workarounds and publish this in a blog or whatever.

    /Freddy
    Freddy Kristiansen
    Group Program Manager, Client
    Microsoft Dynamics NAV
    http://blogs.msdn.com/freddyk

    The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.
  • mihail_kolevmihail_kolev Member Posts: 379
    Sorry for stupid question but is it possible to call for example notepad with some parameter from the RTC?

    i.e.: If i call the 'c:\windows\system32\notepad.exe' as filepath, there is no problem but if i call it with 'c:\windows\system32\notepad.exe 1.txt' (open the 1.txt file in notepad) nothing happens.
    -Mihail- [MCTS]
  • dirkfdirkf Member Posts: 1
    I used the HYPERLINK() function with the relative path to the file \\. Works for me!
Sign In or Register to comment.