Link.UpsertLinks Method

The UpsertLinks method links the specified entities by calling UpsertLink. Currently, only the Document Exchange and Microsoft CRM message formats are supported.

Syntax

[Visual Basic .NET]
Public Sub UpsertLinks(
  ByVal Document1 As String,
  ByVal Document2 As String
)
[C#]
public void UpsertLinks(
  string  Document1,
  string  Document2
);
[C++]
public: void UpsertLinks(
  String*  Document1,
  String*  Document2
);

Parameters

Document1

An XML string containing one to many <message> or <MessageFrame> nodes. See Integration Message Formats for more information.

Document2

An XML string containing one to many <message> or <MessageFrame> nodes. See Integration Message Formats for more information.

Return Value

No return value.

Example

string Document1 = 
   ?<message>
      <message_id>db1a916b-fc42-4b1b-8525-c3541b57c74f</message_id>
      <message_timestamp>2003-12-18T22:44:50Z</message_timestamp>
      <message_action>create</message_action>
      <message_system>Microsoft CRM</message_system>
      <message_objecttype>salesorderdetail</message_objecttype>
      <message_objectid>
         {7BC7E749-90D2-475B-8181-C8B0E8FE9691}
      </message_objectid>
      <message_code>2000</message_code><message_description>
      </message_description>
      <objectxml>
         <salesorderdetails>
            <salesorderdetail>
               <salesorderdetailid>{BA7B5899-9547-447F-81E5-EFA60702BC2E}</salesorderdetailid>
               <salesorderid>{7BC7E749-90D2-475B-8181-C8B0E8FE9691}</salesorderid>
               <salesrepid name="Hill, Annette" dsc="0">
                  {ACD08555-7F12-4B05-9527-DAC080C85E85}
               </salesrepid>
               <isproductoverridden name="Existing">0</isproductoverridden>
               <uomid name="Gallon" dsc="0">
                  {EE8E1ACE-4C7B-4D90-AC42-3E0B4EE522D8}
               </uomid>
               <productid name="Cleaning Solvent" dsc="0">
                  {E991E951-E9E9-43C4-A683-2329F32F1E56}
               </productid>
               <quantity>3</quantity>
               <pricingerrorcode>0</pricingerrorcode>
               <volumediscountamount>0</volumediscountamount>
               <priceperunit>13.5</priceperunit>
               <baseamount>40.5</baseamount>
               <extendedamount>40.5</extendedamount>
               <ispriceoverridden name="Use Default">0</ispriceoverridden>
               <createdon date="12/18/2003" time="2:44 PM">
                  2003-12-18T14:44:25-08:00
               </createdon>
               <createdby name="Hill, Annette" dsc="0">
                  {ACD08555-7F12-4B05-9527-DAC080C85E85}
               </createdby>
               <modifiedby name="Hill, Annette" dsc="0">
                  {ACD08555-7F12-4B05-9527-DAC080C85E85}
               </modifiedby>
               <modifiedon date="12/18/2003" time="2:44 PM">
                  2003-12-18T14:44:25-08:00
               </modifiedon>
               <willcall name="Address">0</willcall>
               <salesorderstatecode>1</salesorderstatecode>
               <lineitemnumber>16384</lineitemnumber>
            </salesorderdetail>
            <salesorderdetail>
               <salesorderdetailid>
                  {B213082E-B6F6-44BD-A375-FDF6E01001A3}
               </salesorderdetailid>
               <salesorderid>
                  {7BC7E749-90D2-475B-8181-C8B0E8FE9691}
               </salesorderid>
               <salesrepid name="Hill, Annette" dsc="0">
                  {ACD08555-7F12-4B05-9527-DAC080C85E85}
               </salesrepid>
               <isproductoverridden name="Existing">0
               </isproductoverridden>
               <uomid name="Each" dsc="0">
                  {1D03C333-781E-4DA0-B75B-664924D86199}</uomid>
               <productid name="4' Stepladder" dsc="0">
                  {58FE4981-4C16-461F-ABBC-C94164AB4A32}
               </productid>
               <quantity>1</quantity>
               <pricingerrorcode>0</pricingerrorcode>
               <volumediscountamount>0</volumediscountamount>
               <priceperunit>30.5</priceperunit>
               <baseamount>30.5</baseamount>
               <extendedamount>30.5</extendedamount>
               <ispriceoverridden name="Use Default">0</ispriceoverridden>
               <createdon date="12/18/2003" time="2:44 PM">
                  2003-12-18T14:44:45-08:00
               </createdon>
               <createdby name="Hill, Annette" dsc="0">
                  {ACD08555-7F12-4B05-9527-DAC080C85E85}
               </createdby>
               <modifiedby name="Hill, Annette" dsc="0">
                  {ACD08555-7F12-4B05-9527-DAC080C85E85}
               </modifiedby>
               <modifiedon date="12/18/2003" time="2:44 PM">
                  2003-12-18T14:44:45-08:00
               </modifiedon>
               <willcall name="Address">0</willcall>
               <salesorderstatecode>1</salesorderstatecode>
               <lineitemnumber>32768</lineitemnumber>
            </salesorderdetail>
         </salesorderdetails>
      </objectxml>
   </message>?;

string Document2 = 
   ?<message>
        <message_id>db1a916b-fc42-4b1b-8525-c3541b57c74f</message_id> 
        <message_timestamp>2003-12-18 22:44:50</message_timestamp> 
        <message_action>create</message_action> 
        <message_system>BackOfficeCompanyDB</message_system> 
        <message_objecttype>SalesDocument</message_objecttype> 
        <message_objectid>2|ORD10015</message_objectid> 
        <message_code>2000</message_code> 
         <message_description>salesorderdetailToSalesDocumentLine</message_description> 
       <objectxml>
          <SalesOrder>
             <SalesLines>
             <SalesLine>
                 <ActualShipDate /> 
                 <GPSFOIntegrationID>none</GPSFOIntegrationID> 
                 <IntegrationID>none</IntegrationID> 
                 <IntegrationSource>1</IntegrationSource> 
                 <ItemDescription>Cleaning Solvent</ItemDescription> 
                 <ItemID>SOLVENT</ItemID> 
                 <LineItemSequence>16384</LineItemSequence> 
                 <NonInventory>0</NonInventory> 
                <OriginatingExtendedPrice>40.5</OriginatingExtendedPrice> 
                 <OriginatingUnitPrice>13.5</OriginatingUnitPrice> 
                 <QTY>3</QTY> 
                 <RequestedShipDate /> 
                 <UOfM>.5GA-3DEC|16384</UOfM> 
                 <KitComponents /> 
              </SalesLine>
             <SalesLine>
                <ActualShipDate /> 
                <GPSFOIntegrationID>none</GPSFOIntegrationID> 
                 <IntegrationID>none</IntegrationID> 
                 <IntegrationSource>1</IntegrationSource> 
                 <ItemDescription>4' Stepladder</ItemDescription> 
                 <ItemID>4' STEPLADDER</ItemID> 
                 <LineItemSequence>32768</LineItemSequence> 
                 <NonInventory>0</NonInventory> 
                <OriginatingExtendedPrice>30.5</OriginatingExtendedPrice> 
                <OriginatingUnitPrice>30.5</OriginatingUnitPrice> 
                 <QTY>1</QTY> 
                 <RequestedShipDate /> 
                 <UOfM>EACH 2|16384</UOfM> 
                 <KitComponents /> 
             </SalesLine>
           </SalesLines>
        </SalesOrder>
     </objectxml>
  </message>?;

UpsertLinks(Document1, Document2);

Preconditions

See the preconditions for UpsertLink.

Postconditions

See the postconditions for UpsertLink.

Expected Errors

The following are expected errors for this method:

Error Description
Microsoft.CRM.Integration.
UnrecognizedMessageTypeException
If the input does not contain either a <message> or <MessageFrame>, this error is raised.
Microsoft.CRM.Integration.
Exception
This error is raised if there are a different number of messages in the Document1 and Document2.

All other exceptions caught are re-thrown inside an error of this type.

Requirements

Namespace: Microsoft.CRM.Integration.Link

Assembly: microsoft.crm.integration.link.dll

See Also