Hi experts,
I got task create web service which update specific record via xmlport. This is first think what I try to do in Dynamic nav.I don’t know is this right way to do.
Inserting new record in table works fine, but even I try to update old record I get this error
"The Sales Header Exists. Identification fields and values:"
But still record is updated.
I write following code in xmlport:
<?xml version="1.0" encoding="UTF-16" standalone="no"?> <Header> <SalesNo>16000604</SalesNo> <CustomerNo>POS</CustomerNo> <ReceiptNo>1234567890</ReceiptNo> <type>Order</type> <ReceiptDate>31.05.10</ReceiptDate> <Lines> <RowNro>10000</RowNro> <Type>Item</Type> <ProductNro>117648</ProductNro> <Title>somethink123</Title> <DocumentType>Order</DocumentType> <documentno>16000604</documentno> </Lines> <Lines> <RowNro>10001</RowNro> <Type>Item</Type> <ProductNro>117648</ProductNro> <Title>somethink1</Title> <DocumentType>Order</DocumentType> <documentno>16000604</documentno> </Lines> </Header>
Document Type"::Order);
IF (SaleHeader.FIND('-')) THEN BEGIN SaleHeader."External Document No.":= '0987654321'; SaleHeader."Order Date":= "Sales Header"."Order Date"; SaleHeader."Sell-to Customer No.":= "Sales Header"."Sell-to Customer No. SaleHeader."Sell-to Address 2":='TESTING TESTING!'; SaleHeader.MODIFY; END; COMMIT;
The key idea is frist check if record is in table, if not then insert it in other case we update exiting record. My xml look like this:
*This post is locked for comments
i did some tests.
everytime you run gXMLP.IMPORT; the loaded sales order will be imported, but it is not possible, because it already exists, so you get that error message.
i removed the gXMLP.IMPORT; command, then retested and got a different error: the connection is closed. the nav service instance was killed, when running the update webservice call. the reason seems to be using instream in the update function, which is then published as web method of the web service. so better rewrite your code.
write a function to load the sales order, then a second function to update the sales order. call both functions then in your c# code. do not use instreams in these functions.
Here is c# code
using (var pd = new PdDataServices())
{
pd.Url = webserviceUrl;
pd.UseDefaultCredentials = true;
pd.AllowAutoRedirect = true;
pd.PreAuthenticate = true;
pd.ModifyRecord(ref header);
}
// return SaleHeader;
Here is code unit code
gFile.OPEN(lCopyFromFile);
gFile.CREATEINSTREAM(gInStream); //Readdata from xml file
gXMLP.SETSOURCE(gInStream);//gXMLP.IMPORT;
gXMLP.IMPORT;
gFile.CLOSE;
please publish the code where you call the webservice (c# ?).
what do you do with the second code sample ?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156