Our support engineers have assembled the top recommended solutions for you.
Microsoft Dynamics AX 2012CRM Connector in Microsoft Dynamics AX 2012Financials Management in Microsoft Dynamics AX 2012Upgrading to Microsoft Dynamics AX 2012
Microsoft Dynamics AX 2009
Application Object Server (AOS)
Enterprise Portal and Role Centers
Inventory Costing in Microsoft Dynamics AX 2009
SSRS and SSAS Integration
I'm interested in running batch jobs from C# code I will be writing. I can't seem to "get it" though. First, I looked at the easiest thing for me: web services. There doesn't SEEM to be such a web service (correct me if I'm wrong). After playing around with that for a while, I moved onto the .NET Business Connector. There're a pair of functions in the "Axapta" class called "CallJob." When I saw this, I thought to myself "Nice, I found it." So I go to use it. The input is "jobName." OK, cool. I went looking for a "Job Name."
.... what's this? Batch Jobs don't have a name associated with them? (or, at least, I don't know where to find them)
Using the batch jobs' IDs didn't work either.
I'm kind of running out of options here. It would seem this can be done, but I haven't found an OUNCE of documentation about how to run batch jobs from an external source (my C# code, for example).
Any ideas???????? I'm at a total loss!
P.S.> What's this "CallJob" function supposed to actually call, anyway?
Your code can't work, I'm surprised that it doesn't throw any error (because you make an instance of abstract class RunBaseBatch). Why don't you simply look into code how batches work? That's the only way how to really understand what you need to do.
First example - create an instance of a some batch class (EventJobCUD in this example), than get its batchInfo, set it to run in batch and call doBatch():
RunBaseBatch batch = new EventJobCUD();
BatchInfo batchInfo = batch.batchInfo();
You have to set any parameters required by the batch, that's when the Batch table comes in handy, because it contains packed parameters. Find your batch, build the instance, set parameters and use it as in the first example:
Batch batch = Batch::findRecId(5637144863);
BatchInfo batchInfo = runBaseBatch.batchInfo();
By the way, parm* methods always return the same value as provided in parameter, that's how the design pattern works.
[ Goshoom.NET Dev Blog ]
Why don't you just implement your own WCF service calling any AX logic you need? See Using Custom Services.
I really need a more generic, non-environment-specific way of doing this. Is that really the only way?
1) There is not such webservice, you would have to write your own.
2) It can be done through Business Connector, but you have to call actual X++ objects handling these things. I think BatchInfo.doBatch() is a good place to start.
3) If you mean Axapta.CallJob(), it really call jobs. Job is a special element in AX AOT; it's basically a static method used for small tasks during development or so.
Thanks I'll look into it...
EDIT: Where is this BatchInfo class? My Microsoft.Dynamics.BusinessConnectorNet namespace doesn't contain such a class... (or ANYTHING with "Batch" in the name for that matter)
EDIT2: I'm assuming from the small amount of research I just did that that's an X++ construct.
SO IN OTHER WORDS, you are telling me that there is no way to run an MS Dynamics AX batch job in a generic fashion, correct? (Like, if I input the Batch Job ID and parameters or w/e)
EDIT3: I still feel as though there must be a way to do this.......
I'm using this code (.NET Business Connector)
var obj = AX.CallStaticRecordMethod("Batch", "findRecId", 5637144863); //this properly locates my batch job
var obj2 = AX.CreateAxaptaObject("RunBaseBatch"); // creates an object
var rv = obj2.Call("parmCurrentBatch", obj); //returns my batch job record, which seems to tell me "it worked"
var rv2 = obj2.Call("doBatch");
This doesn't seem to do anything... at least, my batch job doesn't appear in my batch job history.
What do I call??
Ugh this is so frustrating.
EDIT: The following code had a similar (non-)effect. I only put it in here 'cause you mentioned "BatchInfo" specifically.
var obj = AX.CallStaticRecordMethod("Batch", "findRecId", 5637144863);
var obj2 = AX.CreateAxaptaObject("RunBaseBatch");
var obj3 = AX.CreateAxaptaObject("BatchInfo", obj2);
//var rv = obj2.Call("parmCurrentBatch", obj);
var rv2 = obj3.Call("doBatch", false);
Honestly I was expecting it to throw as well.
Looks like I have my work cut out.
Thank you very much.
Other Microsoft Sites
I'm a Customer
I'm a Partner
Use the official Twitter tags:
#MSDYNCOMM | #CONV13