Tuesday, December 24, 2013

Four steps to extend eConnect

I followed this guide: http://blogs.msdn.com/b/developingfordynamicsgp/archive/2010/12/02/creating-a-custom-serialization-assembly-for-econnect-for-microsoft-dynamics-gp-2010.aspx
step 0 - set VS Command Prompt to your project folder, to make step one easier.
Right-click VS Command Prompt, in Start-In change it to your project folder, click OK. 
Step 1 – Extend the schema
  • Open C:\Program Files (x86)\Microsoft Dynamics\eConnect 12.0\XML Sample Documents\Incoming XSD Individual Schemas\SOPTransaction.xsd
  •    In the SOPTransactionType node add <xs:element minOccurs="0" maxOccurs="1" name="eConnectCustomProcedure" nillable="true" type="eConnectCustomProcedure" />   
  • Note: If you forget the above step, then xsd will not add the class for new type, even if you put the new type complexType info. This drove me mad for a few hours when i forgot this.   
  •    At the bottom of the file, right above </xs:schema> put the following:
 <xs:complexType name="eConnectCustomProcedure">
      <xs:element minOccurs="1" maxOccurs="1" name="CUSTNMBR" type="xs:string" />
  •           For array of objects use

  <xs:complexType name="eConnectCustomProcedure_Items">
      <xs:element minOccurs="0" maxOccurs="unbounded" name="Item" nillable="true">

Step 2 – Use xsd.exe to create the class
1.       Open Visual Studio Command Prompt
2.       Execute xsd “Path To SOPTransaction.xsd (or whatever file you modified” /c
Step 3 – Use the class
  •         Add the class generated by xsd to the project
  •   .  Create the custom node like this

               salesOrder.eConnectCustomProcedure = new eConnectCustomProcedure();
               salesOrder.eConnectCustomProcedure.CUSTNMBR = "CUSTOMER1";

Step 4 – Create the stored proc
create procedure dbo.eConnectCustomProcedure
@I_vCUSTNMBR char(15), /* Customer Number - only required field */
@O_iErrorState int output, /* Return value: 0 = No Errors, Any Errors > 0 */
@oErrString varchar(255) output /* Return Error Code List */
    @CUSTBLNC int,
    @O_oErrorState int,
    @iError int,
    @iStatus smallint,@iAddCodeErrState int
/*********************** Initialize locals ******************************/
    @O_iErrorState = 0,
    @oErrString = '',
    @iStatus = 0,
    @iAddCodeErrState = 0

INSERT INTO TestEConnect (CustomerName) VALUES (@I_vCUSTNMBR)

return (@O_iErrorState)
grant execute on dbo.eConnectCustomProcedure to DYNGRP


No comments:

Post a Comment

There was an error in this gadget