Developer forum

Forum » Integration » Integration Customer Center - Sort Order / New fields

Integration Customer Center - Sort Order / New fields

Ricardo Pereira
Ricardo Pereira
Reply

Hi,

We have two doubts about the Integration Customer Center:

  1. We are using the Integration Customer Center to get Open Orders and Invoices from BC. For both cases, orders are being sorted from oldest to newest. How can we sort them to show the newest ones first? I can't find any option related to the sort order on DW.
  2. The other question is - how can we add new fields to the GetList response? We have tried to use the events GetListOnBeforeAddInvoice and GetListOnAfterAddInvoice, but the values come before or after the item tag (please see image attached).

 

BR,
Ricardo P.
 

Screenshot_1.png

Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Ricardo,
1) It is not implemented. You can try to submit a new feature request for that. You can also try to implement it yourself using the OnAfterErpCommunication Live Integration subscriber

where you can use C# to sort the returned xml in your need order.

2) You can use this subscriber: GetListOnAfterAddInvoice and this code to add your custom fields values:
XMLCurrNode.SelectNodes('//item', xmlNodes);
xmlNodes.Get(xmlNodes.Count, pXmlNode);
XmlHelper.AddField(pXmlNode, 'customFieldName', 'custom field value');

BR, Dmitrij

 
Ricardo Pereira
Ricardo Pereira
Reply

Hi Dmitriy,

Thank you for the quick response.

About the issue 1:
"OnAfterErpCommunicationArgs.Response" is a string, and I can convert it to XML and sort it, but I can't set the response again (OnAfterErpCommunicationArgs.Response) because it's not writable.
And I can see another problem - The response only gets 10 items, so even if we do the sorting, it will only sort those 10 items, because it's being paged.

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Ricardo,
correct, sorry mine suggestion will not work in that case. Maybe we should look of imeplementing a custom subscriber on the BC side using:
OnBeforeExecuteGetListRequest - here you can implement your own response for specific request.
I can send you the currently used source code (to your email) for that so you can add a few lines to sort it on specific field
or
OnAfterExecuteGetListRequest - this where you can use AL to try to sort the generated xml in a proper way.

Then on the live integration side you can subscribe to the Xml generation request and pass the sorting parameter if needed
so it can then be read from the BC subscribers from above.

​BR, Dmitrij

 

 
Ricardo Pereira
Ricardo Pereira
Reply

Hi Dmitriy,

If you could send me the source code it would be awesome.
Thanks for quick answers.

 
Niels Foldager
Reply

Hi Dmitriy,

Will you also send me the source code regarding the sorting issue.

Best regards
Niels Foldager

 
Tomas Gomez
Reply

Hi Dmitrij,

We also need to change the order. Could you please send me the code?

Thanks,
Tomás

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Tomas,
I am not sure you need the source code as this feature was already implemented in one of the latest BC releases 1.2.0.21 and 1.2.0.22:
https://doc.dynamicweb.com/downloads/integration#sideNavTitle1-3

The new behavior works like that:
<GetList type="Invoice" customerID="1234" requestAmount="10" firstItem="10" sortByField="" sortDirection="DESC"></GetList>Two new params added to the GetList request:

sortByField - can be one from the following list:
id  - sort by order No
shipdate - by "Shipment Date"
duedate- by "Due Date"
postingdate- by "Posting Date"
totalamount- by Amount
totalamountincvat - by "Amount Including VAT"
documentdate - by "Document Date"
 
If not set - by default - sorts by "Order Date"

The same sortByFields are for the types "OpenOrder" and "Invoice" and "Credit".

sortDirection - can be:
"asc" - ascending

"desc" - descending (default)

If not set sorts by "desc"

If both params not set sorts by OrderDate desc by default.

Hope this helps
BR, Dmitrij

 
John Cristian Villamar Cueva
Reply

Hi Dmitrij,

What would be the code if what I need is to replace the data of a column?

Should I subscribe to the same event GetListOnAfterAddInvoice?

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi John,
yes, that is the correct event.
Then you can use the codeunit 6211191 DynamicwebXmlHelper
and try to call this method to update the value:
DynamicwebXmlHelper.AddOrUpdateFieldValue(xmlNode, 'YourColumnName', 'YourValue');
BR, Dmitrij

 

You must be logged in to post in the forum