I have a simple import function that imports data from a document and creates sales orders in batch. My problem is that If I add a new price to the priceDiscTable, after the import has been submitted to batch, it doesnt seem to pick up the new price. If I run the import interactively for the same data, the price is correct. The import uses AxSalesTable and AxSalesLine to create the sales order and lines.
Submit import to batch
Create a cheaper price in priceDiscTable
Import creates SalesLine with incorrect price
If I run the same import interactively, for the exact same data, the price is correct.
Both prices are flagged ‘searchAgain’ .
Does that mean you are creating price after initiating the import sales lines batch? If so there may be a chance that the import gets completed before creating the price records.
Have you tried to debug? You can always debug to find the issue.
Debugging batch jobs
Correct, I am creating the new price after the import.
I had thought about caching issues but it seems rather strange that the batch job would access a cached version of table data.
Debugging the import it is in an environment where there are active users, so its not suitable.
Have you tired to initiate the import after creating the price records?
Do you have the updated CIL? (If AX 2012)
You can still debug
The batch job is set to recur every 10 minutes as the import files come at different times of the day.
Restarting the batch server fixes the issue, but this is not ideal, this would require the customer to restart to batch server every time a new price is created.
Update: Not an ideal solution, but I narrowed it down to PriceDisc.findPriceAgreement(), where I set cacheMode to false. I am still no wiser as to why the new records were not being added to the cache if they were not found.
cacheMode = false;
key = this.makeKey(relation,
cacheValue = PriceDisc::getPriceDiscCacheValue(#cacheScope_FindPrice, key);