Pages with subforms in web service (f.e. creating an SO)

Miklos_HollenderMiklos_Hollender Member Posts: 1,598
edited 2009-02-05 in NAV Three Tier
Attempt A: setting up page 42 and 46 both as web services, called SOPage and SOLinesPage.
SOService.SOPage_Service serv = new EnterSalesOrder.SOService.SOPage_Service();
serv.UseDefaultCredentials = true;
serv.Url = "http://localhost:7047/DynamicsNAV/WS/CRONUS_UK_Ltd/Page/SOPage";
SOService.SOPage page = new SOService.SOPage();
page.Sell_to_Customer_No = "10000";
                              
SOLinesService.SOLinesPage_Service lineserv = new SOLinesService.SOLinesPage_Service();
lineserv.UseDefaultCredentials = true;
serv.Url = "http://localhost:7047/DynamicsNAV/WS/CRONUS_UK_Ltd/Page/SOLinesPage";
SOLinesService.SOLinesPage lines = new SOLinesService.SOLinesPage();
lines.No = "1000";
lines.Quantity = 1;
serv.Create(ref page);
lineserv.Create(ref lines);

Problem 1: cannot specify Document No. and Line No. However, this can be probably worked around by adding them to the page.

Problem 2: getting exception: "Namespace "urn:microsoft-dynamics-schemas/page/sopage" in message is invalid, expected "urn:microsoft-dynamics-schemas/page/solinespage"

It seems it doesn't like having 2 different we services referenced?

Attempt B: try to do it all through the Sales Order Page service:
SOService.SOPage_Service serv = new EnterSalesOrder.SOService.SOPage_Service();
serv.UseDefaultCredentials = true;
serv.Url = "http://localhost:7047/DynamicsNAV/WS/CRONUS_UK_Ltd/Page/SOPage";
SOService.SOPage page = new SOService.SOPage();
page.Sell_to_Customer_No = CustomerNo;

SOService.Sales_Order_Line line = new SOService.Sales_Order_Line();
line.No = "1000";
line.Quantity = 1;

serv.Create(ref page);
serv.Create(ref line);


Problem 1: again, cannot specify the Document No. and Line No. but again probably can be resolved by adding it to the page.

Problem 2: doesn't compile, "Argument '1': cannot convert from 'ref EnterSalesOrder.SOService.Sales_Order_Line' to 'ref EnterSalesOrder.SOService.SOPage'"

Apparently you cannot supply the subform as a reference to the Create of the main page.

Attempt C: same stuff, but without the last line

(hoping it will create the line too if I just Create the header, the main page: perhaps it creates every record in the page, including the subforms)

Problem: nope, simply nothing happens, no Sales Line record created.

Any other ideas?

Comments

  • Miklos_HollenderMiklos_Hollender Member Posts: 1,598
    I think the end result is: following the DIY traditions of NAV, use a codeunit-based webservice and code it manually.
  • Tom_CorneliusTom_Cornelius Member, Microsoft Employee Posts: 18
    If I understand correctly, you are trying to create a sales line in an order, correct? You don't need to expose the subform (salesline). Consider this code (it is a PO, but it works the same way):
    // create new purchase order
                Purchase_Order newPurchaseOrder = new Purchase_Order();
                newPurchaseOrder.Buy_from_Vendor_No = "30000";
    
                // set up the lines
                Purchase_Order_Line[] orderLineList = new Purchase_Order_Line[1];
                orderLineList[0] = new Purchase_Order_Line();
                orderLineList[0].Type = PurchaseOrder.Type.Item;
                orderLineList[0].TypeSpecified = true;
                orderLineList[0].No = "1906-S";
                orderLineList[0].QuantitySpecified = true;
                orderLineList[0].Quantity = 2.0M;
                newPurchaseOrder.PurchLines = orderLineList;
    
                // create the order
                purchaseOrderService.Create(ref newPurchaseOrder);
    
    Tom Cornelius
    Test Lead
    Microsoft Dynamics NAV

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Miklos_HollenderMiklos_Hollender Member Posts: 1,598
    Ah, I see. So that's an array of objects. Instantiate the array, and an element, then put the array into the page's container. Or whatever. Something like that. I think I got it. Thanks.

    Could you perhaps arrange it to get this example into the next version of NAV_ADG?
  • DenSterDenSter Member Posts: 8,307
    the next version of NAV_ADG?
    They discontinued the ADG. They included it in Developer Help, well what's left of it. There's a topic about the replacement help (which is not included on the product disc). Apparently we no longer have design standards.
Sign In or Register to comment.