Hello,
I created 1 salesline with AIF Service (SalesSalesOrderService) and another 1 manually using the AX 2012 Client.
The salesline created manually can be updated, but for the one created with my AIF service it is giving me 2 notification:
Field ‘Company’ must be filled in and Field ‘Lot Id’ must be filled in.
Any idea?
Thank you
Ali K. Barada
It means that the two mandatory fields don’t have any value and therefore the validation before saving fails.
Hello Martin,
Unfortunately I am not using those fields in my Business Process in AX 2012, i need to disregard those 2 fields. Maybe while creating the salesorders using the AIF service i forgot a field property that enable those 2 fields to be required.
I don’t need those 2 fields.
Please advise…
Best Regards,
Ali Barada.
What do you mean by “not using those fields”? They’re mandatory at table level, they even make up the primary key of SalesLine table! You can’t ignore them.
If this, then how can i fill them? when i create saleslines using the AIF Service, what are the fields under the AxdEntity_SalesLinerelated to the Lot Id and CompanyId?
A company is normally defined by the call context you provide. And InventTransId is initialized in SalesLine.insert().(I was slightly wrong in my previous answer, because InventTransId isn’t set as mandatory at table leve;, exactly for this defaulting logic.)
You didn’t mention what AX code throw the error and I know nothing about your system, e.g. what customizations you have. I suspect you have something broken there… As always, if you need understand what’s happening, the debugger is the right tool to use.
Hello Martin,
I am creating normally the SalesLine in my code (with fields like itemId, salescategory, unit, quantity and unitprice).
The SaleLine that i create normally in AX 2012 can be updated. The ones created by the service cannot be updated.
Nothing changed in the salesLine customization, it is still the same as per AX 2012 out-of-the-box.
Should i be using the AOT Debbuger? Where should i put the breakpoint? I read many articles regarding the debugger but i am still unable to trigger the event and the beakpoint.
Thank you Martin.
As you probably now, services in AX2012 run in CIL (Common Intermediate Language), not in X++, therefore you can’t use the X++ debugger. (By the way, that’s reason why you have to regenerate CIL after changing X++.) You have to use the Visual Studio debugger with AX Visual Studio tools installed and to attach the debugger to the AOS process. See the steps in Debugging Services in AX 2012.
It will (or should, at least) completely change your approach to analyzing run-time behavior of your services.
Will it work martin if the VS Project is located on another server? (but connecting to AX’s AIF Webservice which is on another server)
There must be something on the machine with AOS that is able to attach to the process. The easiest way is to have Visual Studio there and run debugging locally. Nevertheless you may install only the Visual Studio Remote Debugging Monitor on AOS and communicate with it from Visual Studio on another machine. Find more in Remote Debugging Summary.
I develop and debug locally, nevertheless it’s seems that others use remote debugging with AX2012 sucessfully.
Hello Martin,
thanks a lot, but on more question… updating a salesline in the AX Client 2012 R2, it will trigger what code?
I am able to start debugging the AX Events but i don’t know where I should put a breakpoint.
Best Regards.
Updating a sales line will trigger SalesLine.update() method.
And you can always start from your service, such as in SalesSalesOrderService.update().
Hello Martin,
after several hours of debugging i couldn’t reach the code triggering the issue, therefor i cannot check on the code.
The issue is happening when updating (from AX Client) a SalesLine created by the integration engine (using SalesSalesOrderService). Can you please pass me a correct code in order t create salesline, definitely i am missing a field or something.
Best Regards.
This is a minimalistic solution that works for me in AX 2012 R2 CU7 (without any customizations) and with demo data:
using (var client = new SalesOrderServiceClient())
{
var line = new AxdEntity_SalesLine()
{
ItemId = "D0001",
SalesQty = 42,
SalesUnit = "ea"
};
var order = new AxdEntity_SalesTable()
{
CustAccount = "US-003",
PurchOrderFormNum = "xyz",
ReceiptDateRequested = DateTime.Now.Date,
SalesLine = new AxdEntity_SalesLine[] { line }
};
client.create(
new CallContext() { Company = "USMF" },
new AxdEntity_SalesTable[] { order });
}
Hello Martin,
my code is close to the sample you provided thank you. I don’t know if this help, i am able to update the salesline through the SalesSalesOrderService successfully but i am not able to update the same salesLine through the AX Client.
I couldn’t find the code triggering the warnings by debugging the X++ Code.
Best Regards.
Hi Ali;
Were you able to resolve this, I am facing the exact scenario with purchline. The lines I created through AIF cannot be updated and give the company and lot id error but the lines I created through AX client can be updated.