Problem with Web Service

johntaylormfcjohntaylormfc Member Posts: 22
edited 2009-01-06 in NAV Three Tier
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

Comments

  • Tom_CorneliusTom_Cornelius Member, Microsoft Employee Posts: 18
    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.
  • johntaylormfcjohntaylormfc Member Posts: 22
    Thanks,

    WIll try this.

    Regards

    John
  • ta5ta5 Member Posts: 1,164
    po_line.Quantity = 25;
    po_line.QuantitySpecified = true;

    What's this property? :oops:
    Thanks in advance
    Thomas
  • Tom_CorneliusTom_Cornelius Member, Microsoft Employee Posts: 18
    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.
  • ta5ta5 Member Posts: 1,164
    Thanks!
Sign In or Register to comment.