Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

How to run a codeunit in the background without scheduling in Business Central?

(0) ShareShare
ReportReport
Posted on by 2,203 Super User 2024 Season 1

I have a requirement to run a codeunit in the background every time I click action on a page. I was considering using the job queue, but I am not sure how to configure it to meet my needs. I want the codeunit to run in the background without a set schedule, and I want it to run for each record individually before moving on to the next record. For example, if the code unit takes 15 minutes to run for one record on page and I start the process for another record immediately after, it should be added to the job queue and run only after the first one has completed. How can I set up the job queue to achieve this?
Any help or guidance will be appreciated...
Regards

  • Govinda Kumar Profile Picture
    Govinda Kumar 2,203 Super User 2024 Season 1 on at
    RE: How to run a codeunit in the background without scheduling in Business Central?

    Hi Bilal Haider,

    Thank you for your suggestion. I think creating a table to queue the records to schedule a job queue and run the codeunit for each record and then deleting it from the table can work. I appreciate your help. I will give it a try and let you know how it goes.

    Regards

  • Govinda Kumar Profile Picture
    Govinda Kumar 2,203 Super User 2024 Season 1 on at
    RE: How to run a codeunit in the background without scheduling in Business Central?

    Hi Nitin Verma,

    Thank you for your response, however my requirement is to run the codeunit for each record individually in the background, without a set schedule. Currently, I have set the job whenever I want in the background without worrying about scheduling. The only problem is that if my job takes 15 minutes and I want to set it in the queue for another record, it doesn't get added until the previous job completes..

  • Suggested answer
    Bilal Haider Profile Picture
    Bilal Haider 47 on at
    RE: How to run a codeunit in the background without scheduling in Business Central?

    Hi,

    You can create a table to queue the records you clicked. (Insert as you click)

    Schedule a job queue that will check records in table and run codeunit for that record and delete it after.

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: How to run a codeunit in the background without scheduling in Business Central?

    Hi,

    You need to only schedule a job queue in that case, Job queue will not add any records in-between if its running, it will again restart the processing again, when it finish.

    Thanks.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans