How to check if codeunit is running by other user?

vh8000vh8000 Member Posts: 23
Hi All,

I've created a import codeunit that will import Sales Order from external source, it is running by Job Queue, but user has option to run it manually in case they need to.

My question is how to check if the import codeunit is running? (I want to exit the import if other user/job queue is already running).

Thanks

vh8000

Best Answer

Answers

  • xStepaxStepa Member Posts: 106
    Regards
    xStepa
  • vaprogvaprog Member Posts: 1,139
    edited 2017-08-28
    A single instance codeunit is global in regard to a single client, not a database or company or even a client computer or user (See SingleInstance Property on MSDN).

    As you are probably accessing files anyway, I recommend you create a flag file. Alternatively you can set a "Flag" in the database. You should commit that change, before you start importing.

    Either way, if the importing session terminates for some reason, the flag might get stuck. You need to decide if it is ok for this condition to be detected and corrected by human workers, or if you need to implement an additional watchdog.
  • vh8000vh8000 Member Posts: 23
    Thanks for all suggestions.
Sign In or Register to comment.