Periodic launch of a codeunit - Your opinion

Hi, I’d like to have your opinion about the most easy and effective way to run periodically some objects (codeunit, dataports, etc.). My task is to receive a file from another system, rename it, import it and move the file to a different folder. I already built a codeunit that takes the files, and rename it (plus update a log), and a dataport that imports the data. Both object doesn’t need user interaction if there is no error. My question: What is the best way to have those objects to run periodically? (ex: every 20 minutes)

Since all customers have one Application Server in their license, i would go for this solution. Add NATimer to the codeunit with events, make it single instance, and put you code in the OnTimer trigger. And make the changes on codeunit1/99 to have it run in NAS. /Søren

In our 3.60 Service Management module we have a job scheduler to run objects periodically. I had a go on it an hour ago but until now no objects were run. I’am not sure yet what the problem is (probably me).

Hi. Just try to place some code calling these functions in OnTimer trigger of a newly created form.

About the solution of Pavel (launch from a form with the OnTimer trigger)… Am I right if I say that:

  • The form needs to be opened => a user (client) must be connected
  • There sould be some issues if more than one concurrent users are working with this form opened. Will the SingleInstance property solve this problem?

The SingleInstance property refers to the life cycle of a Codeunit in one Client program, and not across the whole database. If you use a Form/OnTimer solution, only one Client should be running this Form. As an alternative, is it possible to use Job Scheduler from Service Management?

My customer didn’t buy the Service Management.

Then, I would say the fastest solution to implement would be the Form/OnTimer. Put your processing in the OnTimer trigger of the Form, create a special User and set the Main Menu ID in User Setup to your newly designed Form. Then you just have to login with this User and make sure nothing happens to the computer where this Navision Client is running. [;)] PS: did you get around to check the ODBC data source stuff?

Right now, we are am considering using the Application Server, which seems to be the “Navision” way to this, , but I am a bit surprised that the solution requires an “external” application to do a job that is so simple. That’s why I am still looking for other alternatives. Also, could someone confirm that the Job Scheduler can do the job (internally)? A second question: is the job scheduler “company specific”, so that it requires the company to be opened?

quote:


PS: did you get around to check the ODBC data source stuff?


I’m not sure to understand your question. If this can answer… we don’t have the possibility to establish a live (ODBC or C/FRONT) connection with the other database. It would be too complex and too expensive if we compare to the flat file solution.

You should defenitely use NAS for this. It’s perfect for scheduling.

Ok, it it clear to me now that the NAS is the navision way to do scheduling. But if I remember correctly, when you use NAS, you have to specify a company to work in, right? So since my solution has to be implemented for 60 companies in the same database (see http://www.mbsonline.org/forum/topic.asp?TOPIC_ID=8542), how could I use the NAS to do this? Do I use it as a Windows service, or should I go by command line?

As i wrote in the first reply, and Lars in this last … use NAS. It will automatically recover, if it looses connection to the database - a client running a form cannot do this. NAS runs as a service, so you dont have to log in on a machine to start it. Another option, would of course be something like Expandit Launch Utiltiy, which allows you to launch a Navision object (done be kind of macro script, which emulates keystrokes etc.). But this will cost extra in software costs.

As suggested by ‘sv’ read the data in to a table with property Data per company=No. And then when each user logs in, do the approprate actions and postings.

OK. 60 companies is a problem with NAS. Then You need 60 NAS Services to do it right. Then You maybe have to do it Sörens way

BTW: It should be possible to manage unlimited number of companies with just two NAS licenses to do processing periodically. Use one NAS service to control the other one. The first NAS loops trough the company table and starts a second NAS service for the first company. When the processing is done in that company that second NAS service writes a row in a table that is common for all companies. The first NAS service sees this row, stops the second service, goes to the next company and starts a service in that company, and so on. For this You need a service for the first NAS with automatic startup and in Your case 60 other NAS services with manual startup. The first NAS then executes “net start MyNASService” and “net stop MyNASService” for each company. This will work if You have enough time to run the processing sequentially. If You need to run them in parallell You need a NAS license for each company.

quote:


Originally posted by PeterD
In our 3.60 Service Management module we have a job scheduler to run objects periodically. I had a go on it an hour ago but until now no objects were run. I’am not sure yet what the problem is (probably me).


Hi Peter, No it’s not you, I think. You have to fill in a Next Check Date and Next Check Time in the job to have it run. Set the Interval Check in the Job Scheduler Mgt. Setup to 1 second. Then it should work.

Good! Now I have all the information I need to complete the design of the solution. The idea of Lars of having two NAS running to manage unlimited no of companies is very interesting.

Hi David! I’m just wondering if you have tried the solution with two NAS’s? I am about to make a solution to import invoices via XML-files. We are receiving one file that contains invoices to about 70 companies. Regards Magnus

Hi Magnus, We haven’t tried the use of two NAS yet. Right now, we import to a temporary table common to all companies (DataPerCompany = No) and there is a process to get the data launched from each company. This process can be automatically launched, for example, when the form displaying the data is opened in this company (Form - OnOpen), and it “simulates” a live integration. Best Regards, David