Generate Dynamic Lines in EDI File

Hello @Gugi @Alumio_Bot @Ruben I receive incoming Shopify order data in JSON format. Using an Entity Transformer, I convert this data into an EDI format. The Entity Transformer utilizes a Value Setter that uses object type to set value. The values for the EDI format are extracted from the JSON input using the syntax ‘&{}’. This process allows me to transform the Shopify order data into a standardized EDI format for further processing.
Now, in Shopify Orders, there are line_items that are dynamic. In EDI, there is a PO1 loop for adding Product quantities and their titles
image

Based on the provided image, the pattern “PO11" represents items[0], "PO1 2” represents items[1], and so on. These lines can repeat dynamically as “PO13" and beyond. Additionally, the "PID F” line is part of the PO1 loop, and its presence in the EDI format will also be dynamic. How can I achieve this in Alumio Entity Transformer?

The output Results:
image

Hi @fahadmicro

Could you please let me know whether you have tried the entity transformer called Alumio - EDI - Serialize to map a JSON format into EDI? Or, do you want to transform your data manually into EDI using the transformer prototypes?

@Gugi Yes, I have tried to Convert the whole JSON to EDI using the entity transformer called Alumio - EDI - Serialize to map a JSON format into EDI but I got “Bad Request” Error

Therefore, I am manually generating the EDI from JSON format.

@fahadmicro Before using the Alumio - EDI - Serialize, you should transform your order into a JSON format defined in the below file.

json-formatted-x12.json (20.3 KB)

The line items should be mapped into the array Groups.0.Transactions.0.PO1Loop. Additionally, please leave the postfix parameter in the Request Parameters field as an empty string.

The above JSON format will be converted into the below output in X12-standard EDI.

ISA*01*0000000000*01*0000000000*ZZ*ABCDEFGHIJKLMNO*ZZ*123456789012345*101127*1719*U*00400*000003438*0*P*>
GS*PO*4405197800*999999999*20101127*1719*1421*X*004010VICS
ST*850*000000010
BEG*00*SA*08292233294**20101127*610385385
REF*DP*038
REF*PS*R
ITD*14*3*2**45**46
DTM*002*20101214
PKG*F*68***PALLETIZE SHIPMENT
PKG*F*66***REGULAR
TD5*A*92*P3**SEE XYZ RETAIL ROUTING GUIDE
N1*ST*XYZ RETAIL*9*0003947268292
N3*31875 SOLON RD
N4*SOLON*OH*44139
PO1*1*120*EA*9.25*TE*CB*065322-117*PR*RO*VN*AB3542
PID*F****SMALL WIDGET
PO4*4*4*EA*PLT94**3*LR*15*CT
PO1*2*220*EA*13.79*TE*CB*066850-116*PR*RO*VN*RD5322
PID*F****MEDIUM WIDGET
PO4*2*2*EA
PO1*3*126*EA*10.99*TE*CB*060733-110*PR*RO*VN*XY5266
PID*F****LARGE WIDGET
PO4*6*1*EA*PLT94**3*LR*12*CT
CTT*3
AMT*1*13045.94
SE*24*000000010
GE*1*1421
IEA*1*000003438

Please give it a try and let us know if you have any questions.

@Gugi Thanks. I have created the required JSON format and now I am able to use Alumio - EDI - Serialize. Now, I have only one query about how I can handle the PO1 loop i.e. from line_items. I need to know how I can dynamically create an array of objects and use them with my parent data.
image
As there is also an assigned number which increments with each object i.e. PO11, PO12…
Therefore, how will I transform this?

@fahadmicro You can use the Node, transform nodes entity transformer to loop through the line_items in your Shopify order entity. Inside the node transformer, you can then transform each line item to match the Groups.0.Transactions.0.PO1Loop format.

However, in order to get the index of each line item, before entering the above Node transformer, you should put use the Move data between accessors to map the index of line_items array into an accessible property inside the each line_items object. See the below picture.

The above transformer will result in the below PO1loop array.

{
  "PO1loop": [
    {
      "index": "0", // the index
      "line_item": {
        ...
        "id": 669751112,
        "price": "199.99",
        "product_id": 7513594,
        "quantity": 1,
        "requires_shipping": true,
        "sku": "IPOD-342-N",
        "title": "IPod Nano",
        "variant_id": 4264112,
        "variant_title": "Pink",
        ...
      }
    },
    {
      "index": "1", // the index
      "line_item": {
        ...
        "id": 669751113,
        "price": "199.99",
        "product_id": 7513594,
        "quantity": 1,
        "requires_shipping": true,
        "sku": "IPOD-342-N",
        "title": "IPod Nano",
        "variant_id": 4264112,
        "variant_title": "Pink",
        ...
      }
    }
  ]
}

You can use the Node transformer to loop through the PO1loop array instead of looping through the original line_items array.

1 Like

@Gugi Thank You. It worked perfectly.