Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

scheduling batch job with dynamic parameters

(0) ShareShare
ReportReport
Posted on by 795

Hello,

OK. Maybe you can pint me out to the right direction. I have a runbasebatch extended class which I need to schedule on every day at some point in time. Now when I launch this class I see a dialog with the parameters where I can choose them as I wish. It has got 2 date fields. I must schedule this class so that when it's launched as a batch job every day these two parameters are changed. So they kind of dynamic for my batch job. What is the best approach to achieve that? Should I write additional runbasebatch class which will launch this class with these parameters changed dynamically?

6811.JPG

  • dark_knight Profile Picture
    795 on at
    RE: scheduling batch job with dynamic parameters

    I see this in the code.  One class launches another class with some parameters. But I haven't found this class in any scheduled batch jobs. But in the  class in the end method i see this string:

    if (this.isInBatch()||email)
    { some long logic}

    So it expects to be launched via batch job.

    OK. Thanks a lot. I'll try to figure this out further by myself. Many thanks.

  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: scheduling batch job with dynamic parameters

    Hi Azat,

    Normally a class is associated with one batch process.

    How do you think this class is being launched from another runbasebatch class? Please update the cross references and check this.

  • dark_knight Profile Picture
    795 on at
    RE: scheduling batch job with dynamic parameters

    OK. I'll try. Thanks and also do you know is there any function which can tell the class that it's launched by some concrete batch job? Because I saw this class is also launched by some other scheduled runbasebatch class and simply changing dates in run method can affect those batch job but not sure. needs to be checked whether those class passes through any fromdate and todate parameters.

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: scheduling batch job with dynamic parameters

    Hi Azat,

    When the class is running in batch, you can set the from and to dates in the run method. If they are being run manuially, they will take into consideration the from and to dates set in the parameters . Try something like this code in the run method 

    if (this.inbatch())
    {
        fromDate = systemDateGet() - 7;
        toDate   = systemDateGet();
    }

  • dark_knight Profile Picture
    795 on at
    RE: scheduling batch job with dynamic parameters

    Impossible unfortunately because the application is for russian customer and all tags are russian. but these two parameters I interested in are basically fromdate and todate.

  • dark_knight Profile Picture
    795 on at
    RE: scheduling batch job with dynamic parameters

    I already have a ready runbasebatch class. I only need to schedule it for execution every day. Right. Now it's launched manually. But it was designed as runbasebatch class with the dialog from above. These parameters actually are fromdate and todate and they are used in the inner logic of the report. This class generates report and sends it to some people. I need every time this batchjob is launched automatically the first parameter fromdate would be 7 days backwards from the current day. And the parameter todate would be today. Let's imahine it was launhced once. Then it launhced tomorrow. todate parameter should change to today and fromdate parameter again should count 7 days backwards. I hope it helps. Pls ask any other questions.

  • Suggested answer
    Ramit Paul Profile Picture
    22,473 Most Valuable Professional on at
    RE: scheduling batch job with dynamic parameters

    Hi,

    Could you be so kind to share the screen shot in English, please?

  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: scheduling batch job with dynamic parameters

    Hi Azat,

    You are going to set the date parameters for batch job execution which is set for execution every day. Right? How do you want to change these parameters dynamicslly?

    Also, if you are going to set these parameters dynamically, why are you setting this during batch job? Could you please elaborate on the requirement?

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,145 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,896 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans