try { lblError.Text = ""; //Create Header Order SalesOrder = new Order(); SalesOrderService.Create(ref SalesOrder); //Here it increments the Series Number //Update Header SalesOrder.Sell_to_Customer_No = "10000"; SalesOrder.SalesLines = new Sales_Order_Line[2]; //Create Sales Lines for (int idx = 0; idx < 2; idx++) SalesOrder.SalesLines[idx] = new Sales_Order_Line(); SalesOrderService.Update(ref SalesOrder); // Update Sales Line Sales_Order_Line line1 = SalesOrder.SalesLines[0]; line1.Type = Ordini.Type.Item; line1.No = "LS-75"; line1.Quantity = 3; Sales_Order_Line line2 = SalesOrder.SalesLines[1]; //The following article status is blocked line2.Type = Ordini.Type.Item; line2.No = "LS-100"; line2.Quantity = 3; SalesOrderService.Update(ref SalesOrder); //Here it gives the blocked article Error } catch (Exception e) { lblError.Text = e.Message; }
Answers
2) otherwise : search where the COMMIT is, and do a test: The problem is: you have to find all COMMIT. And if later on, someone adds a commit,.....
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Is one transaction and it is being called twice, hence two transactions.
These are the options.
1. Delete the any records created if you get any error.
2. Write the data into staging table and call a NAV function to create the PO and if errors out to delete the data from staging table.
3. Create a codeunit with a function and pass XMLport as paramter. I haven't tried this yet.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I think that the third option is the most suitable for me.
LnZ
This is what I would suggest also. Though I would not delete the data if there is an error, I would add a status field and mark the order as failed, this gives you an audit trail and lets the user check what went wrong, Then once resolved, flush out the old data.
For example if they typed their zip code wrong, then the user should get the error and after they fix it resend it from the web.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n