Problem with Web Service

johntaylormfc
Member Posts: 22
Hi,
My colleague has written the following code to try and create a PO via web services. We have published the Purchase Order Page as a service.
void btn_2_Click(object sender, EventArgs e)
{
//Create instance of Purchase Order Service
Nav2009_Service.Purchase_Order_Service service_PO = new Nav2009_Service.Purchase_Order_Service();
service_PO.UseDefaultCredentials = true;
//Create Instance of Purchase Order
Nav2009_Service.Purchase_Order PO = new Nav2009_Service.Purchase_Order();
//Set Purchase Order Properties
PO.Buy_from_Vendor_No = "01587796";
PO.Status = Nav2009_Service.Status.Pending_Approval;
//Create Lines
Nav2009_Service.Purchase_Order_Line po_line = new Nav2009_Service.Purchase_Order_Line();
po_line.No = "LS-S15";
po_line.Quantity = 25;
po_line.Type = Nav2009_Service.Type.Item;
po_line.Description = "Item Description";
//Add the lines to the order
PO.PurchLines = new Nav2009_Service.Purchase_Order_Line[] {po_line};
//Create Purchase Order
service_PO.Create(ref PO);
Response.Write(PO.No);
}
Everything works fine, the item description pulls through in the lines when we validate the item no.
po_line.No = "LS-S15";
However we cannot get the quantity to pull through from this line.
po_line.Quantity = 25;
Should we be doing something differently. My colleague is off for a couple of weeks so I thought I would try here for a resolution.
I have noticed he is setting type last which shoudl INIT the line, but the item no. remains, so this does not seem to be the issue.
Thanks
John
My colleague has written the following code to try and create a PO via web services. We have published the Purchase Order Page as a service.
void btn_2_Click(object sender, EventArgs e)
{
//Create instance of Purchase Order Service
Nav2009_Service.Purchase_Order_Service service_PO = new Nav2009_Service.Purchase_Order_Service();
service_PO.UseDefaultCredentials = true;
//Create Instance of Purchase Order
Nav2009_Service.Purchase_Order PO = new Nav2009_Service.Purchase_Order();
//Set Purchase Order Properties
PO.Buy_from_Vendor_No = "01587796";
PO.Status = Nav2009_Service.Status.Pending_Approval;
//Create Lines
Nav2009_Service.Purchase_Order_Line po_line = new Nav2009_Service.Purchase_Order_Line();
po_line.No = "LS-S15";
po_line.Quantity = 25;
po_line.Type = Nav2009_Service.Type.Item;
po_line.Description = "Item Description";
//Add the lines to the order
PO.PurchLines = new Nav2009_Service.Purchase_Order_Line[] {po_line};
//Create Purchase Order
service_PO.Create(ref PO);
Response.Write(PO.No);
}
Everything works fine, the item description pulls through in the lines when we validate the item no.
po_line.No = "LS-S15";
However we cannot get the quantity to pull through from this line.
po_line.Quantity = 25;
Should we be doing something differently. My colleague is off for a couple of weeks so I thought I would try here for a resolution.
I have noticed he is setting type last which shoudl INIT the line, but the item no. remains, so this does not seem to be the issue.
Thanks
John
0
Comments
-
Hi John,
In general, you need to set the associated xxxSpecified property to true when modifying non-string properties. For example,
po_line.Quantity = 25;
po_line.QuantitySpecified = true;Tom Cornelius
Test Lead
Microsoft Dynamics NAV
This posting is provided "AS IS" with no warranties, and confers no rights.0 -
Thanks,
WIll try this.
Regards
John0 -
Tom Cornelius wrote:po_line.Quantity = 25;
po_line.QuantitySpecified = true;
What's this property? :oops:
Thanks in advance
Thomas0 -
This is to tell NAV that a non-nullable property has been modified. It is to ensure that a value is not overwritten with uninitialized data. You'll need to use it for modifying ints, decimal, enums, etc.Tom Cornelius
Test Lead
Microsoft Dynamics NAV
This posting is provided "AS IS" with no warranties, and confers no rights.0 -
Thanks!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