serving the solutions day and night

Pages

Saturday, June 8, 2013

Create/Update/Delete Dynamics CRM 2011 Entity Record from BizTalk 2010 Server

Create Dynamics CRM 2011 Entity Record from BizTalk 2010 Server

1)Create new map (MCRM_Create.btm)

2)Select Source Schema (SAuditXML), Desitnation Schema(DNS_BTS_CRM.organixationservice_schemas_microsoft_com_xrm_2011_contracts_services -> Create)

3)Rename Page name (Enity), make EnityName(source) link to LogicalName(Destination)



4)Add another page (Loops), add Looping shape from toolbox. AuditNumber (int), First(string), Discharge(datetime), County(entity reference id), Audit(optionset value) - make linke to Looping and from Looping to KeyValuePairOfstringanyType.


5)Add another page (Datas), add 5 scripting shape from toolbox. Make link to Scripting and key (KeyValuePairOfstringanyType).
 Doublclick the AuditNumber scripting, select 'Inline XSLT Call Template' from Script Functiod Configuration, enter the below xslt(int type)
 <xsl:template name="SetAuditNumberValue">
     <xsl:param name="param1" />
     <key xmlns="http://schemas.datacontract.org/2004/07/System.Collections.Generic">dns_auditnumber</key>
     <value xmlns="http://schemas.datacontract.org/2004/07/System.Collections.Generic"
         xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:    xsi="http://www.w3.org/2001/XMLSchema-instance">
         <xsl:attribute name="xsi:type">
             <xsl:value-of select="'xs:int'" />
         </xsl:attribute>
         <xsl:value-of select="$param1" />
    </value>
</xsl:template>

First Scripting xslt code (string type)
 <xsl:template name="SetFirstNameValue">
     <xsl:param name="param1" />
     <key xmlns="http://schemas.datacontract.org/2004/07/System.Collections.Generic">dns_firstname</key>
     <value xmlns="http://schemas.datacontract.org/2004/07/System.Collections.Generic"
         xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:    xsi="http://www.w3.org/2001/XMLSchema-instance">
         <xsl:attribute name="xsi:type">
             <xsl:value-of select="'xs:string'" />
         </xsl:attribute>
         <xsl:value-of select="$param1" />
    </value>
</xsl:template>


Discharge Scripting xslt code (datetime type)
 <xsl:template name="SetDischargeDateValue">
     <xsl:param name="param1" />
     <key xmlns="http://schemas.datacontract.org/2004/07/System.Collections.Generic">dns_dischargedate</key>
     <value xmlns="http://schemas.datacontract.org/2004/07/System.Collections.Generic"
         xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:    xsi="http://www.w3.org/2001/XMLSchema-instance">
         <xsl:attribute name="xsi:type">
             <xsl:value-of select="'xs:dateTime'" />
         </xsl:attribute>
         <xsl:value-of select="$param1" />
    </value>
</xsl:template>


County Scripting xslt code (entity reference type)
<xsl:template name="SetCountyValue">
    <xsl:param name="param1" />
    <key xmlns="http://schemas.datacontract.org/2004/07/System.Collections.Generic">dns_countyid</key>
    <value xmlns="http://schemas.datacontract.org/2004/07/System.Collections.Generic"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts">
           <xsl:attribute name="xsi:type">
                <xsl:value-of select="'a:EntityReference'" />
           </xsl:attribute>
           <Id xmlns="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:ser="http://schemas.microsoft.com/2003/10/Serialization/">
              <xsl:attribute name="xsi:type">
                 <xsl:value-of select="'ser:guid'" />
            </xsl:attribute>
             <xsl:value-of select="$param1" />
        </Id>
           <LogicalName xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">dns_county</LogicalName>
           <Name xmlns="http://schemas.microsoft.com/xrm/2011/Contracts" />
    </value>
</xsl:template>


Audit Scripting xslt code (optionset value type)
<xsl:template name="SetAuditStatusValue">
    <xsl:param name="param1" />
    <key xmlns="http://schemas.datacontract.org/2004/07/System.Collections.Generic">dns_auditstatus</key>
    <value xmlns="http://schemas.datacontract.org/2004/07/System.Collections.Generic"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts">
           <xsl:attribute name="xsi:type">
            <xsl:value-of select="'a:OptionSetValue'" />
           </xsl:attribute>
           <Value xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
               <xsl:value-of select="$param1" />
       </Value>
    </value>
</xsl:template>


6)Create new orchestation (CreateService)
 Add 3 messages, MesCreate_Input(sAuditXML), MesCreate_CRMRequest(DNS_BTS_CRM.IOrganizationService_Create_InputMessage), MesCreate_CRMResponse(DNS_BTS_CRM.IOrganizationService_Create_OutputMessage)
 Add Receive -> (ReceiveRequest,MesCreate_Input)
 Add Port -> (PortReceive, opReceive, PortTypeReceive, receiving), add link to ReceiveRequest
 Add Transform -> (CM_Receive(MesCreate_CRMRequest), TransReceive(Exiting Map->MCRM_Create, Source->MesCreate_Input, Destination->MesCreate_CRMResponse.parameters))
 Add Send (SendReceive, MesCreate_CRMRequest)
 Add Receive (ReceiveResposne, MesCreate_CRMResponse)
 Add Send (SendResponse MesCreate_CRMResponse)
 Add Port -> (PortSendRespnse, opReceive, PortTypeSendRespnse, sending), add link to SendResponse
 Add Port -(PortCRMService, exiting port type (IOrganizationService), sending and receiving), add Create Request link to SendReceive and Create Response link to ReceiveResponse
 

7)Build and Deploy the project.
input
<ns0:Audit xmlns:ns0="http://DNS_BTS_CRM.SFAXML">
  <Select>
    <EntityName>gab_audit</EntityName>
  </Select>
  <List>
    <AuditNumber>123456</AuditNumber>
    <Name>
      <First>First_0</First>
    </Name>
    <Date>
      <Discharge>2010-05-10T00:00:00.000-05:00</Discharge>
    </Date>
    <Address>
      <County>33294ecd-f4ed-e111-9564-0050568c5ad0</County>
    </Address>
    <Status>
      <Audit>810520001</Audit>
    </Status>
  </List>
</ns0:Audit>


output
<?xml version="1.0"?>
    <CreateResponse xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services"><CreateResult>64b89301-f5ce-e211-bc9e-0050568c2ee8</CreateResult></CreateResponse>

Update Steps
1)Create new map (MCRM_Update.btm)

2)Select Source Schema (SAuditXML), Desitnation Schema(DNS_BTS_CRM.organixationservice_schemas_microsoft_com_xrm_2011_contracts_services -> Update)

3)Rename Page name (Enity), make EnityName(source) link to LogicalName(Destination), ID -> id


4)Add another page (Loops), same as above step 4, added extra one field Last (string).

5)Add another page (Datas), same as above step 5, add one more scripting xslt code for Last

6)Create new orchestation (UpdateService)
 Add 3 messages, MesUpdate_Input(sAuditXML), MesUpdate_CRMRequest(IOrganizationService_Update_InputMessage), MesUpdate_CRMResponse(IOrganizationService_Create_OutputMessage)
Exiting Map->MCRM_Update
 follow the above Create Steps 6)

Update Response
<?xml version="1.0"?>
<UpdateResponse xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services"/>

Delete
1)Create new map (MCRM_Delete.btm)

2)Select Source Schema (SAuditXML), Desitnation Schema(DNS_BTS_CRM.organixationservice_schemas_microsoft_com_xrm_2011_contracts_services -> Delete)

3)make EnityName(source) link to LogicalName(Destination), ID -> id

4)Create new orchestation (DeleteService)
 Add 3 messages, MesDelete_Input(sAuditXML), MesDelete_CRMRequest(IOrganizationService_Delete_InputMessage), MesDelete_CRMResponse(IOrganizationService_Delete_OutputMessage)

Delete Response
<?xml version="1.0"?>
<DeleteResponse xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services"/>

No comments: