# How to create a MES to MES Integration Entries using DEE, please give an example code, thanks a lot!

**URL:** <https://community.criticalmanufacturing.com/t/how-to-create-a-mes-to-mes-integration-entries-using-dee-please-give-an-example-code-thanks-a-lot/606>\
**Category:** Integrations\
**Tags:** v11.3, other\
**Created:** [March 19, 2026, 6:10am UTC](https://community.criticalmanufacturing.com/t/how-to-create-a-mes-to-mes-integration-entries-using-dee-please-give-an-example-code-thanks-a-lot/606 "2026-03-19T06:10:55Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Ricardo\_Cunha](https://yyz2.discourse-cdn.com/flex050/user_avatar/community.criticalmanufacturing.com/ricardo_cunha/32/1133_2.png) [@Ricardo\_Cunha](https://community.criticalmanufacturing.com/u/Ricardo_Cunha)\
**Post date:** [September 8, 2026, 1:06pm UTC](https://community.criticalmanufacturing.com/t/how-to-create-a-mes-to-mes-integration-entries-using-dee-please-give-an-example-code-thanks-a-lot/606/2 "2026-09-08T13:06:07Z")

</div>

Hi Joy,

In order to create a new integration entry via DEE, you can follow the sample code below. This sample creates a new integration entry from “MES to MES” using the Message Type “CreateIntegrationEntrySample”. The JSON payload consists of an array of objects representing dummy material data.

```auto
// Foundation
        UseReference("Cmf.Foundation.BusinessObjects.dll", "Cmf.Foundation.BusinessObjects.Abstractions");

        // System
        UseReference("%MicrosoftNetPath%\\System.Text.Json.dll", "System.Text.Json");
        UseReference("", "System.Text");

        #region Service Provider

        IServiceProvider _serviceProvider = (IServiceProvider)Input["ServiceProvider"];
        IEntityFactory _entityFactory = _serviceProvider.GetService<IEntityFactory>();

        #endregion Service Provider

        // Demo payload: a Materials array with a couple of sample entries
        var payload = new
        {
            Materials = new[]
            {
                new { MaterialId = "MAT-0001", Name = "Sample Material 1", PrimaryQuantity = 10.0 },
                new { MaterialId = "MAT-0002", Name = "Sample Material 2", PrimaryQuantity = 25.5 }
            }
        };

        string message = System.Text.Json.JsonSerializer.Serialize(payload);

        var newIntegrationEntry = _entityFactory.Create<IIntegrationEntry>();
        newIntegrationEntry.Name = Guid.NewGuid().ToString();
        newIntegrationEntry.SourceSystem = "MES";
        newIntegrationEntry.TargetSystem = "MES";
        newIntegrationEntry.MessageType = "CreateIntegrationEntrySample";
        newIntegrationEntry.EventName = "CreateIntegrationEntrySample";
        newIntegrationEntry.SystemState = IntegrationEntrySystemState.Received;

        var integrationMessage = _entityFactory.Create<IIntegrationMessage>();
        integrationMessage.Message = Encoding.UTF8.GetBytes(message);
        newIntegrationEntry.IntegrationMessage = integrationMessage;

        newIntegrationEntry.Create();

```

Please ensure the message type is added to the **MessageType** lookup table.

To process this entry you can create another DEE. That DEE does not need any action group and receives the context Integration Entry through its input dictionary:

```csharp
IIntegrationEntry integrationEntry = Input["IntegrationEntry"] as IIntegrationEntry;

```

Finally, to connect all the dots, you need to update the **IntegrationHandlerResolution** smart table, with the respective integration entry metadata (source, target and message type). Enter the _GenericIntegrationHandler_ as the handler type and add the name of the DEE that will process the message on _Action Name_.

---

_[View the full topic](https://community.criticalmanufacturing.com/t/how-to-create-a-mes-to-mes-integration-entries-using-dee-please-give-an-example-code-thanks-a-lot/606)._
