Global CHANGECOMPANY

dagviggodagviggo Member Posts: 20
Does anybody have any suggestions on how to post orders from a NAS client to different companies.

Here's what I'm trying to do...

I have a NAS client that listens to reqests from a web site. And this web site "talks" to several companies in Navision thru heavy use of CHANGECOMPANY. In most cases this works fine, but when we get to posting for instance orders in Navision this gets complicated.
Because Codeunit 80 calls a bunch of different functions and uses several tables.
What I really would love is to be able to changecompany globall within the current client, then my problem would be solved. But no such thing exists as far as I know.

Any help would be appreciated!

Comments

  • HalMdyHalMdy Member Posts: 429
    Is this because you speak about "Global" subject that you make a Global Request in all the sections ? :whistle:
  • WaldoWaldo Member Posts: 3,412
    As far as I know, this is not possible.

    What we did:
    We use 2 NAS clients. One controls the other. for changing company: it stops the service, it changes the parameters, and it starts the service again. This way, it can post whatever it wants... without worrying about CHANGECOMPANY...

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • dagviggodagviggo Member Posts: 20
    Sorry about the multiple posts! I was afraid that would miss some geniuses out there.
  • dagviggodagviggo Member Posts: 20
    Thanks Waldo, that sound like a great idea - eventhough I don't have any idea of how to start/stop services from within NAS, but we'll look into it.

    Maybe, another post arises after a few trials and errors :wink:
  • WaldoWaldo Member Posts: 3,412
    well,

    we wrote a seperate DLL that does this ... quite easy in VB.NET. Else you would run a shell-command like "NET STOP" and "NET START" to stop and start services.

    Basically the DLL does the following:
    - Stop service
    - Change registry settings (for the NAS)
    - Start service

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • dagviggodagviggo Member Posts: 20
    That's true, I didn't think of NET START/STOP. But there's one thing I'm wondering about.

    Does your DLL routine wait for the NAS process to complete before closing it and preparing the next request.
    If it doesn't, then you would need X number of NAS clients, depending on how many reqests there are before the first one finishes.

    And NAS clients costs money :(

    Are you with me?!
  • WaldoWaldo Member Posts: 3,412
    indeed, that's what the first one does. There is a mechanism included to detect if the second NAS has completed the job. Only then, the next job can be started...

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • dagviggodagviggo Member Posts: 20
    that's what I thought. We'll try with at loop in NAS1 that waits for NAS2 to finish.

    Thanks a lot, we have come a long way today :D
  • kinekine Member Posts: 12,562
    What about something as "switch"? It is some NAS which get the message, look at it and send it to target NAS based on the Company you need. (one NAS for each company + 1 NAS switch). The switch can be something else, not NAS.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • WaldoWaldo Member Posts: 3,412
    Can you explain more clearly ... don't get it exactly.

    you mean that you need a NAS for each company?

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • kinekine Member Posts: 12,562
    Yes, to not need CHANGECOMPANY, you start NAS for each company (problem is only licenced sessions for NAS).

    a) you send request to one of the NAS, it look at it, see that it is for his company (then process it) or it is for another company (than forward it to another NAS)

    b) you have extra NAS, which take the request and forward it to apropriate NAS for the company...
    variant A
           request
              | 
             NAS2    
              |   \
            NAS3    NAS4
    
    variant B
             request
               |
              NAS1---------
            /    \        \
          NAS2    NAS3      NAS4
    
    
    Where NAS1 is the 'switch NAS', NAS2 is NAS for Company1, NAS3 is NAS for Company 2, NAS4 for Company 3 etc...[/quote]
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • WaldoWaldo Member Posts: 3,412
    How many NAS-licenses do you need then? 2?

    I like the second option ... . Pretty straight forward... .

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • kinekine Member Posts: 12,562
    You need NAS session for each NAS (one you have for free) + one for the 'switch' if you do it with NAS (it can be another application)...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • WaldoWaldo Member Posts: 3,412
    hm, that's may be a disadvantage... . They're quite expensive ... and when you're having about 30 companies ... well, you can do the math... .

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • dagviggodagviggo Member Posts: 20
    One more thing Waldo, you with the experience :wink: ...

    What is the performance like?!? When you all the time have to, start NAS, then wait for process to finish and then close NAS, when processing requests.
  • WaldoWaldo Member Posts: 3,412
    depends on the job, of course. If you have a job that lasts a few hours, no other will run. For some customers we have multiple NAS instances. The controlling NAS controls all Executing NAS's.

    Stopping and starting a NAS doesn't take much time ... .

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • aleix1979aleix1979 Member Posts: 213
    What about creating a bool var + Origin Var in one company1, create the bill from company2 making this bill as "automatic-post/don't-show" and "Origin". Then to also have a infinite loop in company 1(spare PC1) that checks and posts all those bills and mark in Company 2 the origin bill for them all. Then a second loop in company 2 (spacre PC2) that checks all "Waiting bills" and post them when receiving the confirmation from company 1.

    That would take 2 sessions and no need to post from another company (which is impossible unless you want to duplicate all posting codeunits and related) That will also allow people like me which doesn't have a dumb about how to create a dll to do so. Rolling Eyes

    The only problem would be to control the waiting bills (presumably you would hide those from the regular forms).

    PD: Sorry, admin
    Navision Developer
Sign In or Register to comment.