Web Service Insert Order Roll Back

LnZ
Member Posts: 37
Hi,
I'm inserting an order via Web Services and wolud like to do a complete roll back if there are some errors (eg: a Sales Line with a blocked Item), I don't want to increment the Sales Series Number if the order is not inserted.
Is it possible?
LnZ
P.S.:Sorry for my bad English.
Here is my code:
I'm inserting an order via Web Services and wolud like to do a complete roll back if there are some errors (eg: a Sales Line with a blocked Item), I don't want to increment the Sales Series Number if the order is not inserted.
Is it possible?
LnZ
P.S.:Sorry for my bad English.
Here is my code:
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; }
0
Answers
-
1) webservice NAV2009 (the original without hotfix) has a bug: the COMMIT command does NOT do a COMMIT!
2) otherwise : search where the COMMIT is, and do a test:IF NOT ISSERVICETIER THEN COMMIT;
The problem is: you have to find all COMMIT. And if later on, someone adds a commit,.....Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
I don't think there is a COMMIT issue in here
SalesOrderService.Update(ref SalesOrder);
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.0 -
Thank You ara3n,
I think that the third option is the most suitable for me.
LnZara3n wrote:
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.0 -
ara3n wrote: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.
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.David Singleton0 -
Yes, I use that for most integration. It would depend on who the user is on the web and what kind of error you would get.
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.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions