Quantcast
Channel: Art Of Creation - Dynamics AX Blog » Job
Viewing all articles
Browse latest Browse all 9

Run multiple jobs

$
0
0

I’ve noticed some people are visiting this blog looking for code that runs multiple jobs, so here’s a job that does just that.

static void KlFor_runMultipleJobsContainer(Args _args)
{
    #AOT                    // macro for treenode paths
    Container   jobCont;    // container for jobs
    int         i;          // counter for loop
    ;

    // add jobs to the container
    jobCont = conins(jobCont, conlen(jobCont) + 1, "klforjob2");
    jobCont = conins(jobCont, conlen(jobCont) + 1, "klforjob3");
    jobCont = conins(jobCont, conlen(jobCont) + 1, "klforjob2");    // run klforjob2 again

    // loop all elements of the container
    for(i = 1; i <= conlen(jobCont); i++)
    {
        // check if the job exists to avoid errors
         if(TreeNode::findNode(strfmt(#JobPath, conpeek(jobCont, i))))
        {
            // run job
            TreeNode::findNode(strfmt(#JobPath, conpeek(jobCont, i))).AOTrun();
        }
    }
}

Easy enough :).


Viewing all articles
Browse latest Browse all 9

Trending Articles