Options

Job Queue for Unlimited Company

24

Comments

  • Options
    ara3nara3n Member Posts: 9,255
    You need to install One NAS. Nas will run itself with different startup parameter and run for different company.
    As long as the Startup Parameter starts with 'JOBQUEUE2|' NasHandler function in CU 1 will run the correct CU.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    RachelSoonRachelSoon Member Posts: 202
    Hi ara3n,
    Any ideas to solve the problem that i posted on May 29?
    Any sugesstion?

    thank you.

    Regards
    Rachel
  • Options
    ara3nara3n Member Posts: 9,255
    RachelSoon wrote:
    Hi ara3n,
    I have tried the NAV 5 standard, the job queue work fine. Then i imported the objects for job queue for unlimited company.

    The job got triggered and executed fine if WIHTOUT assigning the company name at the "Job Queue Entry Card".

    Once assign the company name, the job (to run a report) got started by prompting a blank command prompt window with the current directory at the title bar.
    The report suppose to update some information at the customer card, however, nothing has been updated.

    Is there anything wrong / setup that i have missed out?

    Kindly advise.

    Thank you.

    Regards
    Rachel

    I just tested and run an example report. It works fine.
    How many NAS licenses do you have on your license?

    Nav gives you 1 NAS user for free. You need to purchase 1 extra NAS user.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    RachelSoonRachelSoon Member Posts: 202
    Hi ara3n,
    I checked our NAV license, and granule 1420 Application Server is 10.

    Are you refering to the lincese for this granule?

    By the way, why do we need 2 NAS user? as we only has 1 service for the job queue.

    Thank you.

    Regards
    Rachel
  • Options
    ara3nara3n Member Posts: 9,255
    Yes you've installed one NAS service, but with this mod, NAS runs itself (becomes two instances) connected to Server.


    As far as granule, I don't know the number, I don't have the granule excel file with me right now.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    fedepolfedepol Member Posts: 4
    Hi ara3n,

    I have to post an invoice from company A to Company B. From the company A i've to insert and post an invoice into Company B. I can use ChangeCompany to insert data into tables (for example 36 e 37), but how can I do the posting into Company B?

    Do yuo think that the "Job Queue for Unlimited Company" could help me in some way? Do you know any other solution?

    Thank you.
    Regards
    Monica
  • Options
    ara3nara3n Member Posts: 9,255
    You can definitely use job queue to do the posting.
    Basically you'll have job queue doing the posting for each company. Nav client will write the SO, and then write into Job queue entry table and wait till record is processed.

    Take a look at this post on how to insert the order into job queue entry

    http://blogs.msdn.com/microsoft_dynamic ... v-5-0.aspx


    How high is the volume of orders, and how many company do you have?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    fedepolfedepol Member Posts: 4
    There are only two company.

    Users open a company, maybe A or B, select an order and post the invoce in the company set on the item. Naturally all items in the order are referred to a specific comapany by a field that we have added in the table 27.

    Thanks for your attention.
    Monica
  • Options
    ara3nara3n Member Posts: 9,255
    In that case just just run standard NAV Job queue for each company. And write record in the other company Job queue entry as in the above link and wait till it gets processed by NAS.

    If posting errors then grab the error and you need to specify how you want to proceed.

    Hope this makes sense.

    One NAS for each company A and B (need to purchase One more NAS).

    From Company A Write Order to Company B. Write entry into job queue entry of Company B. Wait for NAS to post in Company B. If successful then continue, else take appropriate action.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    rdebathrdebath Member Posts: 383
    Oh I'd forgotten about this.
    Okay, it's not difficult to make a NAS that hops between companies, and you only need one NAS and it works with 3.01B (this is when I tried it).

    First you need the DLL that's used by the windows to configure the NAS.
    NasControl	Automation	'nascontrol 1.0 Type Library'.NAS_Control
    

    Next you need the service name of the NAS.
    NasName	Code		30
    

    Then you just set it:
    CREATE(NasControl);
    NasControl.ServiceName := NasName;
    NasControl.put_NASProperty('company', "New Company Name");
    NasControl.ServiceConfigurationChanged();
    
    The NAS will switch companies when the current trigger exits.

    Use an NFTimer as normal to get control back.
    NFTimer	Automation	'Navision Timer 1.0'.Timer
    
    Timer.Interval := 500;
    Timer.Enabled  := TRUE;
    EXIT(TRUE);
    

    If you want to log error messages use the error event trigger.
    NFTimer::TimerError(ErrorString : Text[1024])
    

    Seems to be reliable, if a little slow.
  • Options
    ara3nara3n Member Posts: 9,255
    Here is another solution using webservices.


    viewtopic.php?f=32&t=31476

    You don't need to purchase a second expensive NAS.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    MonstaMonsta Member Posts: 38
    Hello, ara3n!
    Thank you for your job. It really helped!
    I have a problem, though. In case there are any quotation marks (") in company name, job fails. In fact, 2nd application server fails to start and Job Queue log contains an error with company name without quotation marks (see attached image). If company name is renamed (quotation marks are removed), everything works fine.
    Of course, we can rename the company, if there is not the other solution. What would you suggest?
  • Options
    ara3nara3n Member Posts: 9,255
    I would try and change the CU and add Double quotes to the Company parameter.

    Change the code
    'company='                      + JobQueueEntry."Company Name" + ','+
    


    to

    'company="' + JobQueueEntry."Company Name" + '",'+
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    MonstaMonsta Member Posts: 38
    ara3n wrote:
    I would try and change the CU and add Double quotes to the Company parameter.

    Change the code
    'company='                      + JobQueueEntry."Company Name" + ','+
    


    to

    'company="' + JobQueueEntry."Company Name" + '",'+

    Hello. Adding additional quotes did not help. Anyway, we have already renamed companies, so the problem is not an issue anymore.

    Yet we have another problem: everything works fine on Windows 2003 server, but on Windows 2008 server the 2nd application server hangs up - it never starts. I tried to test the functionality by starting codeunit 448 directly. In this case black command line window appears (which is run to start application server) and no further actions are performed. Job queue entries are not processed. What could be the reason?
  • Options
    ara3nara3n Member Posts: 9,255
    I haven't tested in windows 2008.
    if you run the CU manually.


    Make sure that this is where you installed NAS, If not change the string in the red section to the correct directory.

    WindowShell.CurrentDirectory('C:\Program Files\Microsoft Dynamics NAV\Application Server\')
    ELSE
    WindowShell.CurrentDirectory(APPLICATIONPATH);
    txtCommand := 'NASSQL servername=' + Server."Server Name" + ','+
    'database=' + Session."Database Name" + ','+
    'company=' + JobQueueEntry."Company Name" + ','+
    'nettype=TCP,startupparameter=' + 'JOBQUEUE2|'+COMPANYNAME+'|'+FORMAT(JobQueueEntry.ID);
    WSHExec := WindowShell.Exec(txtCommand);

    Also manually from from command prompt try to start the NAS. AND make sure txtCommand is well formatted based based on your results.
    Also see what APPLICATIONPATH returns in NAV on 2008. It should return the same directory where NAS is installed.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    MonstaMonsta Member Posts: 38
    Thank you, ara3n, for your reply.

    I have further testing results.
    But first more information about environments:
    Windows 2003 server - is our testing environment. As I've said before - everything works fine here.
    Windows 2008 server - client's production system. The problem is on this environment.

    So, I've decided to do the following on the client's environment:
    1. I've installed application server on another computer, running win.xp and tried to run the functionality -> same problem.
    2. Next, I've installed 2 separate application servers (2 services) - one server for each company - and have set up jobs in each company -> everything works fine.

    Something wrong is in whole environment, the server is not the one rising issue, I guess. 2nd application server cannot be started by the 1st NAS.
    ara3n wrote:
    Make sure that this is where you installed NAS, If not change the string in the red section to the correct directory. WindowShell.CurrentDirectory('C:\Program Files\Microsoft Dynamics NAV\Application Server\')
    Yes, I have already changed it. We have different directory: 'C:\Program Files (x86)\Microsoft Dynamics NAV\Application Server\'
    ara3n wrote:
    Also see what APPLICATIONPATH returns in NAV on 2008. It should return the same directory where NAS is installed.
    Yes, that's correct. C:\Program Files (x86)\Microsoft Dynamics NAV\Application Server\
    ara3n wrote:
    Also manually from from command prompt try to start the NAS. AND make sure txtCommand is well formatted based based on your results.
    I have copied txtCommand variable value from debugger and tried to start NAS manually. It started, although I had to add few quotation marks (") to startup parameter:
    NASSQL servername=MYSERVERNAME,database=My Database Name,company=My Test Company,nettype=TCP,startupparameter="JOBQUEUE2|Master Database Name|{E0013D2F-B34B-48B6-8614-C761EB7F3041}"
    The quotation marks I've added to code:
    'nettype=TCP,startupparameter=' + '"JOBQUEUE2|' + COMPANYNAME + '|' + FORMAT(JobQueueEntry.ID) + '"';
    

    Any ideas?
  • Options
    ara3nara3n Member Posts: 9,255
    Check your PM.
    I would need to look at 2008 server.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    MonstaMonsta Member Posts: 38
    I found where the problem was! \:D/
    SQL server, DB settings: client had CS (case sensitive) database ](*,)
    The main company, Job Queue jobs were run from, had lower and upper case characters in its name. When the company name was passed through NAS it has been converted to upper case. Then in codeunit (Run NAS Accross Company) the company was supposed to be fetched from "Company" table and the action could not be completed. Here is the code:
    IF NOT Company.GET(txtFromCompany) THEN BEGIN
      MESSAGE(txtFromCompany);
      EXIT;
    END;
    
    This type of error was not handled in portion of code analyzing NAS command promt output.

    I changed the code in Codeunit "Run NAS Accross Company" as follows:
    Function OnRun()
    IF NOT Company.GET(txtFromCompany) THEN BEGIN
      MESSAGE('Company was not found ' + txtFromCompany);  //Added constant text string
      EXIT;
    END;
    
    Function RunNasForOtherCompany()
    IF STRPOS(Responseline,Text0003) <> 0 THEN BEGIN
        EXITNAS := TRUE;
        StandardError := TRUE;
      END;
      //Added >>
      IF STRPOS(Responseline,'Company was not found') <> 0 THEN BEGIN
        EXITNAS := TRUE;
        StandardError := TRUE;
      END;
      //Added <<
    

    Of course, the company name has to be renamed in this case (or additional code has to be added to handle name conversion back to its original state).

    Thank you very much, ara3n, for your help and the piece of functionality :thumbsup:
  • Options
    andy76andy76 Member Posts: 616
    Hello,

    I read the first posts. I am in this situation:
    - I only have 2 companies A and B
    - I actually have only 1 standard NAS granule
    - I need to run a report that import data in company A reading from a text file (and this should go right with the NASSQL installation a 1 standard granule)
    - I also need to run another report on company B alway for import data reading from a text file.

    I ask you:
    - this solution is not for me because I only have 2 companies and need to buy however the second NAS granule. Is that correct? I don't need unlimited company but only two.
    - is it possible to use only first NASSQL connected to company A to run also the second report loading data on company B using something like CHANGECOMPANY or this is not recommented if I use for example validate functions? The report insert and modify data on table Customer.

    Thank you
  • Options
    ara3nara3n Member Posts: 9,255
    On what version are you on?

    If you are on 2009, I could offer a better solution.

    Thanks.

    you can also contact rdebath and look at his solution I haven't tried that one.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    andy76andy76 Member Posts: 616
    For this customer we have NAV 5.0 SP1

    Thanks
  • Options
    ara3nara3n Member Posts: 9,255
    You will need a second NAS.
    As you mentioned you can use changecompany but validation does not run in the other company.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    andy76andy76 Member Posts: 616
    Are 2 granules of NAS compulsory or only the one standard is enought?

    The configuration is only 1 server with SQL Server 2008 and NASSQL on same machine. The database from which to run NASQL is only 1 but the companies to connect are 2.

    Thank you very much.
  • Options
    rdebathrdebath Member Posts: 383
    Okay, summary time (aka RTFT).

    One NAS can only run in one company at a time.

    There are several hacks to allow the company a NAS is in to be changed 'on the fly' but they all need the NAS to be restarted/reloaded which can take upto a minute to complete. The simplest is to use a batch file from the windows task scheduler.

    The NAV2009 version is different in that runs the actual job code using the NAV 2009 web service (service) the NAS still runs in one of the companies but the task isn't run directly by the NAS.

    See the rest of this thread for the various methods.
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    rdebath wrote:
    The NAV2009 version is different in that runs the actual job code using the NAV 2009 web service (service) the NAS still runs in one of the companies but the task isn't run directly by the NAS.

    What do you mean with this? AFAIK they have not changed the NAS in 2009 and you do not need webservices for the Job Queue.

    Webservices does not even have a time mechanism but is event driven.
  • Options
    rdebathrdebath Member Posts: 383
    I mean Rashed's (ara3n) contribution in this thread.

    ie: the link to http://www.mibuso.com/forum/viewtopic.php?f=32&t=31476
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Ah I see. Missed that sorry.

    I agree that it is interesting to try and do this. Currently I am working on a project where I want an interface to be event driven rather than timer driven.

    I'll explore this idea. Thanks.
  • Options
    ara3nara3n Member Posts: 9,255
    Mark you are not following my blog? :mrgreen:
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    I try, but it is not published on dynamicsusers.org so I have to think about it manualy. ](*,)

    I should start using rss.

    It's a good blog with creative ideas.
  • Options
    ara3nara3n Member Posts: 9,255
    Use google reader.

    I only go to google reader and stopped going to any site. All my rss feed are there and it saves me a lot of time.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.