Running different page versions based on company

dashenk23dashenk23 Member Posts: 40
edited 2012-01-31 in NAV Three Tier
I'm trying to find a way in RTC to be able to run different versions of pages by company, for example a Sales Order or Customer Card...I can create the additional pages, but can't figure out a way to change which one runs depending on the company. Does anyone know of a solution for this? Thanks in advance for any help!

Comments

  • deV.chdeV.ch Member Posts: 543
    I've done somehting similar, a module that can be enabled or disabled, the modul replaces standard pages.

    This code needs to be run on the OnOpen Trigger
      IF ISSERVICETIER THEN BEGIN
        IF NOT Job.GET("No.") THEN
          BaseVersion.RunHyperlinkRTC(0,3032014,3)
        ELSE BEGIN
          JobCard2.SETTABLEVIEW(Rec);
          JobCard2.SETRECORD(Rec);
          JobCard2.RUN;
        END;
        ERROR('');
      END ELSE BEGIN
        JobCard2.SETTABLEVIEW(Rec);
        JobCard2.RUNMODAL;
        JobCard2.GETRECORD(Rec);
        CurrPage.CLOSE;
      END;
    
    The Error(''); is needed because you can't run currpage.close on the OnOpen trigger (known issue, reported to MS, this is their workaround), it just closes the page.
    RunHyperlinkRTC(): Is a function that runs a Hyperlink to open the Card in New-Mode, otherwise you can't use the standard "sparkle" new buttons


    Here is the RunHyperlinkRTC Function:
    RunHyperlinkRTC(_ObjectType : 'Page,Report';_ObjectNo : Integer;_Mode : ' ,View,Edit,Create')
    // BASIS037
    IF NOT ISSERVICETIER THEN
      ERROR('GetHyperlinkStringRTC() is only available on Service Tier');
    
    GetServerAndServiceName(ServerTxt,PortTxt,ServiceTxt);
    CASE _ObjectType OF
      _ObjectType::Page   : RunObjectTxt := STRSUBSTNO('runpage?page=%1',_ObjectNo);
      _ObjectType::Report : RunObjectTxt := STRSUBSTNO('runreport?report=%1',_ObjectNo);
    END;
    HyperlinkTxt += STRSUBSTNO('DynamicsNAV://%1:%2/%3/%4/%5',ServerTxt,PortTxt,ServiceTxt,Utility.URLEncode(COMPANYNAME),RunObjectTxt);
    IF _Mode <> _Mode::" " THEN
      HyperlinkTxt += STRSUBSTNO('&mode=%1',_Mode);
    
    ExecuteShell(HyperlinkTxt);
    
    Name DataType Subtype Length
    Utility Codeunit Online Map Utilities

    And the last one:
    GetServerAndServiceName(VAR _ServerTxt : Text[30];VAR _PortTxt : Text[30];VAR _ServiceTxt : Text[30])
    IF NOT ISSERVICETIER THEN
      ERROR('GetServerAndServiceName() is only available on Service Tier');
    
    IF ISCLEAR(WSHNetwork) THEN
      CREATE(WSHNetwork);
    
    IF ISCLEAR(DomDoc) THEN
      CREATE(DomDoc);
    
    _ServerTxt := WSHNetwork.ComputerName();
    
    DomDoc.load(APPLICATIONPATH + 'CustomSettings.config');
    
    DomNode := DomDoc.selectSingleNode('//appSettings/add[@key=''ServerPort'']');
    IF NOT ISCLEAR(DomNode) THEN
      _PortTxt := DomNode.attributes.item(1).text; // Server Port
    
    DomNode := DomDoc.selectSingleNode('//appSettings/add[@key=''ServerInstance'']');
    IF NOT ISCLEAR(DomNode) THEN
      _ServiceTxt := DomNode.attributes.item(1).text; // Server Name
    
    CLEAR(DomDoc);
    CLEAR(WSHNetwork);
    
    IF (_ServerTxt = '') OR (_PortTxt = '') OR (_ServiceTxt = '') THEN
      ERROR('Error loading NST Config File');
    
    Name DataType Subtype Length
    DomDoc Automation 'Microsoft XML, v3.0'.DOMDocument
    DomNode Automation 'Microsoft XML, v3.0'.IXMLDOMNode
    WSHNetwork Automation 'Windows Script Host Object Model'.WshNetwork
  • kinekine Member Posts: 12,562
    In some cases RTC is opening the correct page based on the properties on table. You cannot change this behavior in this way (or you need to change many thing to code instead using properties of buttons etc.)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • deV.chdeV.ch Member Posts: 543
    Hi Kine, that's exactly the reason for my solution. this way you only have to put code in the OnOpen Trigger of the original Page (in my example it was Job Card).
    every time Job Card should be opened, my enhanced job card gets opened instead. Pages defined in Properties are supported too.
  • kinekine Member Posts: 12,562
    WHat about cases where the page is lookup page and you need to return the result Action? Or you add some function and you are running the page through variable and you are using this function to return some data? Or you are strictly using it in the standard "way" of opening the lookup?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • deV.chdeV.ch Member Posts: 543
    Lookup works fine, you can use Getrecord to achieve that. Of course complex situations like returning values running modally etc, are not the idea of this. It's designed to use it the standard "just open the page with this record"-way.

    For result action i guess that's not possible.

    Functions could be implemented in the alternative Page as well and called after the Runmodal to give the result back to the original caller.

    I don't say it's the best thing to do, or even recommend this [-X but i think most of the requirements can be done with this.

    btw: 2009 R2 is required for the hyperlink function.
  • kinekine Member Posts: 12,562
    Thanks for the details. It looks like good solution for given case... 8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • mdPartnerNLmdPartnerNL Member Posts: 802
    ExecuteShell(HyperlinkTxt);

    @deV.ch

    Im using hyperlink(..) for this and sometimes it errors out for no reason. Would you mind sharing that function ExecuteShell() ?
  • deV.chdeV.ch Member Posts: 543
    ExecuteShell simply does this:

    Name DataType Subtype Length
    WSH Automation 'Windows Script Host Object Model'.WshShell
    IF ISCLEAR(WSH) THEN
      CREATE(WSH,TRUE,TRUE);
    WSH.Run(_Comand);
    
  • mdPartnerNLmdPartnerNL Member Posts: 802
    deV.ch wrote:
    ExecuteShell simply does this:

    Name DataType Subtype Length
    WSH Automation 'Windows Script Host Object Model'.WshShell
    IF ISCLEAR(WSH) THEN
      CREATE(WSH,TRUE,TRUE);
    WSH.Run(_Comand);
    

    Thanks, has this too but it didn't start. Just revisited the code and noticed the create "run on client" parameter.. :oops:

    How do you bypass the security warning from NAV?
  • deV.chdeV.ch Member Posts: 543
    Security warning should only occur once (click always allow) so this is not a problem for us.
    But I guess if you set up SPN then you wouldn't get a message at all.
  • mdPartnerNLmdPartnerNL Member Posts: 802
    Sorry im talking about this message:

    Microsoft Dynamics NAV Security Notice
    You are about to connect to 'DynamicsNAV' on server 'vm004', which is not your current default connection setting.

    This can create a security risk.

    Do you want to continue?

    Yes No
  • deV.chdeV.ch Member Posts: 543
    Does this help you?: http://www.mibuso.com/forum/viewtopic.php?t=39876

    If you are working on your default instance (like it should be in a normal customer environment) you won't get this message.

    Are you using a custom shortcut (for connecting to a specific instance) in you scenario?
  • mdPartnerNLmdPartnerNL Member Posts: 802
    That was it. Im using a Virtual Machine as a server but didn't set it as default in the .config file.

    Sorry for going off topic and thx.
  • deV.chdeV.ch Member Posts: 543
    No problem, you are welcome ;)
  • raveendran.sraveendran.s Member Posts: 119
    I had a similar requirement. What I did is, I added a Option field in the Company information. based on the selection the required page has to be opened.

    And then from the Menusuite, I removed the page and added a codeunit, which checks for the company information and opens the page accordingly.

    It was possible for me as I removed all the default menuitems from the menu and given limited options.
    --
    Regards,
    Raveendran.BS
Sign In or Register to comment.