Run codeunit

lubostlubost Member Posts: 621
We need to run specific codeunit (OnRun trigger) and stop session afterwards from Windows Task scheduler. Our issues:
- for logged user client shows message to confirm connection (-consolemode parameter doesn't help)
- for not logged user codeunit isn't invoked. Event viewer reports unspecified error - probably concerning confirm connection message
- STOPSESSION command in our codeunit stop session, but shows unwanted message

Our codeunit doesn't need user interaction and interafce.
We need run this codeunit independently to other running NAV services. We use MS Dynamics NAV 2017 environment.
Any suggestion will help.
Thanks in advance


  • Options
    vaprogvaprog Member Posts: 1,130
    Can you use the Job Queue or TASKSCHEDULER.CREATETASK instead from within NAV?

    What do you mean by "logged" user? The user must be registeres as a NAV user and must have permission within NAV to access, whatever your codeunit accesses. This is true regardless of how you try to run the codeunit.
  • Options
    lubostlubost Member Posts: 621
    Thanks for response,
    Task Scheduler can be configured to invoke task not depending to user is logged on machine.
  • Options
    vaprogvaprog Member Posts: 1,130
    Although you may set up a task in Windows scheduled tasks, you cannot run any NAV business logic without beeing authenicated with NAV. If you don't want to use a Windows user for running your codeunit, you need to set up an NST with a different authentication scheme and still create a NAV user.

    I don't know if it is possible (and advisible) to supply full credentitials on the command line in order to use e.g. the user + password authentication scheme. I guess, the only option you have then is a call to a Web Service.
Sign In or Register to comment.