set a value to repeated elements using xpath at orchestration
-
Tuesday, November 29, 2011 7:31 AM
I am tring following xpath expression to assign value to repeated elements
xpath(msgAxaptaToDyn._nsy_CreateSalesOrder,/*[local-name()='Nsy_CreateSalesOrder' and namespace-uri()='http://schemas.microsoft.com/dynamics/2008/01/documents/Nsy_CreateSalesOrder']/*[local-name()='NSY_SalesTable_1' and namespace-uri()='http://schemas.microsoft.com/dynamics/2008/01/documents/Nsy_CreateSalesOrder']/*[local-name()='NSY_SalesLine_1' and namespace-uri()='http://schemas.microsoft.com/dynamics/2008/01/documents/Nsy_CreateSalesOrder']/*[local-name()='MessageID' and namespace-uri()='http://schemas.microsoft.com/dynamics/2008/01/documents/Nsy_CreateSalesOrder'])="sssss";
but it showing following error
xlang/s engine event log entry: Uncaught exception (see the 'inner exception' below) has suspended an instance of service 'NORSKSynergi.EDIOrdersToAxapta.SyncOrder(35e87d47-5552-c0fa-8f7b-199da78925d5)'.
The service instance will remain suspended until administratively resumed or terminated.
If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.
InstanceId: 6cfc427c-2849-4d0d-adec-9b508b9bcb4e
Shape name: ConstructMessage_AxaptatoDyn
ShapeId: ec55c95c-df07-4d45-ad4f-f43ed12a9253
Exception thrown from: segment 1, progress 16
Inner exception: The XPath expression '/*[local-name()='Nsy_CreateSalesOrder' and namespace-uri()='http://schemas.microsoft.com/dynamics/2008/01/documents/Nsy_CreateSalesOrder']/*[local-name()='NSY_SalesTable_1' and namespace-uri()='http://schemas.microsoft.com/dynamics/2008/01/documents/Nsy_CreateSalesOrder']/*[local-name()='NSY_SalesLine_1' and namespace-uri()='http://schemas.microsoft.com/dynamics/2008/01/documents/Nsy_CreateSalesOrder']/*[local-name()='MessageID' and namespace-uri()='http://schemas.microsoft.com/dynamics/2008/01/documents/Nsy_CreateSalesOrder']' selected a node which is not valid for property or distinguished field retrieval, or it selected no node at all. Only text-only elements or attributes may be selected.
Exception type: XPathSelectionException
Source: Microsoft.XLANGs.Engine
Target Site: Void XPathStore(System.Object, System.String)
The following is a stack trace that identifies the location where the exception occured
at Microsoft.XLANGs.Core.Part.XPathStore(Object rValue, String xpath)
at NORSKSynergi.EDIOrdersToAxapta.SyncOrder.segment1(StopConditions stopOn)
at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)
All Replies
-
Tuesday, November 29, 2011 9:19 AM
If your xpath is returning multiple nodes then it will not work as you cannot update a node-set this way.
What you can do is
1) inside the orchestration use xpath to count the number of elements, then using looping shape you can access and update each one of them by using xpath and specifying the exact location
nodesCount = xpath(message,'count(/*[local-name()='node1] /*[local-name()='node2])')
currentIndex = 1
for 1 to nodesCount
xpath(message,'/*[local-name()='node1] /*[local-name()='node2]['+currentIndex+']/*[local-name()='MessageID']
currentIndex = currentIndex + 1
2) make this update in a a c# helper class
-
Tuesday, November 29, 2011 11:46 AM
This can be done in orchestration using map&custom xsl file(for-each,if) .
Srikanth Peddy. MCTS-BizTalk Server Please mark as answered .- Marked As Answer by kishore chokkapu Wednesday, November 30, 2011 4:59 AM
-
Tuesday, November 29, 2011 1:32 PM
There is another scenario where if the filed is not present then you will get this error. If it is not a repeating element, then make sure in your map this particular filed is marked as "Empty" in the value property or have a string contenation functoid and connect to this element. The string functoid can be empty.
Thanks
SKGuru

