Dynamic query in batchjobs

Hi All,

We are using Microsoft Dynamics AX2012 and we are struggling with a dynamic query for massive invoicing (in batch). We would like to invoice all packingsliplines with deliverydate smaller than 2 days ago, so we fill custpackingsliplines.deliverydate with (lessThanDate(-2)).

When we execute this query in the client, the correct packingsliplines are returned for invoicing. But when we plan it as a batch job all the packingsliplines will be invoiced. When we take a look at the query in batchjob the line with the dynamic query is removed.

Has anyone a solution for this problem?

Something is wrong in how you set the range to your batch. For example, you merely changed an AOT query and the batch still uses the previous query saved in usage data.

Hi Martin,

Thanks for your answear.

Do you have any idea how to solve it? Also when we put it not to the batch (but just execute the query on the client) the range is also removed when we ask AX to show the query again. We found out that adding the same datasource to the query again and put the range on the new datasource will work like we expect.

I may be able to tell you how to solve it if you tell what’s the problem. I explained one possible cause, but I’ve got no information from you whether it’s the case or not. And because I didn’t hear anything about your query, how you changed it, how it’s used by your batch, about results of your debugging and anything, it was really wild guess. I’m not going to keep guessing.

Hi Martin,

Thanks for your help. Deleting usage data from the used query for the batch user was solving the problem.