HomeGuides
Submit Documentation FeedbackJoin Developer CommunityLog In

Creating a custom integration processor for order submit

This topic describes how to create a custom integration processor for order submit, and configure the Admin Console for the integration job.

In this article we are going to create a custom Integration Processor for Order Submit, and configure the Admin Console for the integration job. This example uses a local SQL Server database as a fake ERP to complete the job. This job will work for any ERP of your choice.

πŸ“˜

Note

All source code and db scripts used in this article can be found in the attached zip file so you don't have to re-type anything.

The first step for creating a custom Integration Processor is to ensure that B2B Commerce Cloud and your respective ERP have established a connection. See screen shot below for a sample integration job connection:

πŸ“˜

Note

In this example the backend ERP is a SQL Server database hosted locally.

The next step is to create the integration definition for the job. Submitting order data requires several parameters and steps specifically configured for the order submit type of integration job. When a customer clicks the Check Out button, B2B Commerce Cloud looks for a job called Order Submit. Because of this, an Order Submit job must be created to fulfill this request.

Creating an Order Submit Job

  1. In the Admin Console, go to Administration > Jobs > Job Definitions.

  2. Click Add Job Definition to create a new job.

  3. In Job Name enter Order Submit.

    πŸ“˜

    Note

    This job must be called Order Submit due to the way Insite Handlers search for the job. To name the job something else, the handler must be overridden.

  4. In Job Type, select the Submit value.

  5. In Connection, enter in the connection value. In this example the connection value is FakeERP.

    πŸ“˜

    Note

    There are three processor types: Preprocessor, Integration Processor, and Post Processor. Each processor has several different fields available.

  6. In Preprocessor select GenericSubmit. (GenericSubmit populates the CustomerOrder table. Using the out of the box GenericSubmit, requires a parameter in the job step called Order Number.)

  7. In Integration Processor select the value None.

    πŸ“˜

    Note

    We will change this value later, once we've written our custom integration processor to describe what is happening in the WIS.

  8. In Post Processor select the ProcessSubmitResponse value.

  9. Click Save to complete saving the job.

  10. Go to the Steps finger tab.

  11. Click Add Job Definition Step to add a new step.

  12. In Sequence, set the value to 1.

  13. In Step Name, enter in the value SubmitOfAnOrder.

  14. In Target Object, select the Cart value.

    πŸ“˜

    Note

    We select the Cart value because it will resolve to the Customer Order entity.

  15. Click Save. Clicking Save lets you access the Job's Parameter and Field Mapping fields.

  16. Click the Job Step's Parameters finger tab.

  17. Click Add Job Definition Step Parameter.

  18. In Name, enter in the value OrderNumber.

  19. In Default Value, set the value to 0. This is the value if someone wants to run the job from within the Admin Console.

  20. In Prompt, enter in the message that will be shown when users run the job from the Admin Console.

  21. Click Save to save the job parameter.

Creating a Custom Integration Processor within Visual Studio

At this point, we are now ready to create our custom integration processor.

  1. From within Visual Studio, create a new class library called Training.Integration.

  2. Add these references to the class library:

    • Insite.Common
    • Insite.Integration
    • Insite.WIS.Broker

    The insite. references are required by B2B Commerce Cloud methods, while System.Runtime.Serialization is needed due to the way B2B Commerce Cloud uses data sets.

  3. Add a new class called IntegrationProcessorFakeERPSubmit.

    If you start the beginning of the class name with "IntegrationProcessor", then by convention the system will use whatever is after "IntegrationProcessor" as the name of the Integration Processor in the drop down list located in the Admin Console on the Details tab of the integration job. So in this example the Integration Processor drop down list will contain the value of "FakeERPSubmit".

    Now that the class has been created, the class needs to be groomed. (See screen shot located after the steps below.)

  4. Implement the IIntegrationProcessor interface.

  5. Implement the ConnectionString.

  6. Add a Job Logger. The Job Logger is able to provide alert messages, information, warnings, and so on.

  7. Implement the execute method.

    • From within the execute method, create a data set that can be set up and returned. The parameters that were created earlier (siteConnection, integrationJob, JobStep) are passed along and contain the information that is required, including the data set.

    • Create "this.JobLogger = new IntegrationJobLogger (siteConnection, integrationJob);"

  8. Capture the data set that was passed over from the integration job preprocessor using "var initialDataset = XmlDataset.convertXmlToDataset (integrationjob.InitialData)". This XML dataset comes with the Insite.Common.Helpers library.

  9. Grab the data row for the customer order using "var dataRowCustomerOrder = intitialDataset.tables [Data.CustomerOrderTable].Rows [0];"

  10. Define the customer and order numbers using, "string customerNumber = dataRowCustomerOrder [Data.CustomerNumberColumn].ToString ();" and "string orderNumber = dataRowCustomerOrder [Data.orderNumberColumn]. ToString ();"

    πŸ“˜

    Note

    This example has a simple orders table containing two columns: OrderNumber and CustomerNumber. Other fields could be added, however for this example these are the only fields we are gathering.

  11. Call to SQL using "string sqlString - String.Format("INSERT INTO.Order (OrderNumber, CustomerNumber) VALUES ('{0}','{1}')", orderNumber, customerNumber).

  12. Create a SQL connection using the connection string crated earlier, "SqlConnection sqlcnn = new SqlConnection(cnn);

  13. Create a SQL command with the connection string using, "SqlCommand cmd = new SqlCommand (sqlString, sqlcnn);

  14. Add a log entry to tell users that work has been completed, "JobLogger.Info("Finished Processing Order.",);

  15. Open the Connection. "sqlcnn.Open();

  16. Run the SQL command. "cmd.ExecuteNonQuery();

  17. Close the connection. "sqlcnn.Close();

  18. Return the initial data set. "return initialDataSet;"

  19. Build the project. Once the build completes go to the Training.Integration folder within your project and copy the Training.Integration.dll file.

  20. Go to the install path of the WIS and paste the Training.Integration.dll file into your dll folder. (Make sure to stop the WIS service first before copying in the dll file. Once the file is in your dll folder then start the WIS service again.)

  21. Verify in your WIS logfile.txt that you see the following: "Found Custom Integration Processor FakeErpSubmit, registering in Unity".

  22. Return to the Admin Console to complete the configuration of the integration job definition.

  23. Go to the Order Submit job built earlier.

  24. In the Integration Processor field select the newly created processor "FakeErpSubmit."

If properly set up, a newly completed order will write a record in your FakeERP Orders table.


Did this page help you?