Numeric field values using Web Services

tpbrophy
Member Posts: 12
Successfully used web service (NAV 2009 SP1) to add records to two tables. However, fields that are either date, integer or decimal are not being updated with the values assigned to the fields in the C# application.
Here is an extract of the code:
// Create an instance of Shopping Cart Header
ShoppingCartHeader SCHeader = new ShoppingCartHeader();
SCHeader.Shopping_Cart_No = "1234H";
SCHeader.Customer_Name = "Mary Jones";
SCHeader.Address = "1234 Bermuda Drive";
SCHeader.City = "Chicago";
System.DateTime orddate = new DateTime(2009, 9, 30);
SCHeader.Order_Date = orddate;
SCHeader.State = "IL";
SCHeader.ZipCode = "60609";
// Create an instance of Shopping Cart Line array
ShoppingCartLine[] SCLineArray = new ShoppingCartLine[4];
for (int i = 0; i < SCLineArray.Length; i++)
{
decimal j;
SCLineArray = new ShoppingCartLine();
SCLineArray.Shopping_Cart_No = SCHeader.Shopping_Cart_No;
SCLineArray.Line_No = (i+1) * 10000;
SCLineArray.Shopping_Cart_No += SCLineArray.Line_No.ToString();
j = (decimal)i+1;
SCLineArray.Product_ID = ((j*10000)+j).ToString();
SCLineArray.Product_Name = "Test Item " + j.ToString();
SCLineArray.Quantity = j.ToString();
SCLineArray.Unit_Price = (decimal)(j * 125);
SCLineArray.Extended_Price = j * SCLineArray.Unit_Price;
}
// Insert Shopping Cart Header
serviceHeader.Create(ref SCHeader);
for (int i = 0; i < SCLineArray.Length; i++)
{
serviceLine.Create(ref SCLineArray);
SCLineArray.Product_Name += "Again";
serviceLine.Update(ref SCLineArray);
}
Thanks in advance.
Here is an extract of the code:
// Create an instance of Shopping Cart Header
ShoppingCartHeader SCHeader = new ShoppingCartHeader();
SCHeader.Shopping_Cart_No = "1234H";
SCHeader.Customer_Name = "Mary Jones";
SCHeader.Address = "1234 Bermuda Drive";
SCHeader.City = "Chicago";
System.DateTime orddate = new DateTime(2009, 9, 30);
SCHeader.Order_Date = orddate;
SCHeader.State = "IL";
SCHeader.ZipCode = "60609";
// Create an instance of Shopping Cart Line array
ShoppingCartLine[] SCLineArray = new ShoppingCartLine[4];
for (int i = 0; i < SCLineArray.Length; i++)
{
decimal j;
SCLineArray = new ShoppingCartLine();
SCLineArray.Shopping_Cart_No = SCHeader.Shopping_Cart_No;
SCLineArray.Line_No = (i+1) * 10000;
SCLineArray.Shopping_Cart_No += SCLineArray.Line_No.ToString();
j = (decimal)i+1;
SCLineArray.Product_ID = ((j*10000)+j).ToString();
SCLineArray.Product_Name = "Test Item " + j.ToString();
SCLineArray.Quantity = j.ToString();
SCLineArray.Unit_Price = (decimal)(j * 125);
SCLineArray.Extended_Price = j * SCLineArray.Unit_Price;
}
// Insert Shopping Cart Header
serviceHeader.Create(ref SCHeader);
for (int i = 0; i < SCLineArray.Length; i++)
{
serviceLine.Create(ref SCLineArray);
SCLineArray.Product_Name += "Again";
serviceLine.Update(ref SCLineArray);
}
Thanks in advance.
0
Comments
-
How are you adding records? Are you doing an Insert from C# or calling a command? Can you post some of the C# code you are using?
Tim0 -
The webservice is doing validation of field in order they are defined. Thus when validating field "No.", nearly all other fields are cleared. Do not forget about this...0
-
Thanks, Kamil. That worked. However, when a table (e.g. Sales Line) has a multi-field primary key the "...No." field is populated on the insert and the secondary fields are populated on the update.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