# Required rule must have the respective row in the source file

**URL:** <https://connective.celigo.com/t/required-rule-must-have-the-respective-row-in-the-source-file/254>\
**Category:** Integrator.io\
**Tags:** fixed-width, error-handling, json\
**Created:** [January 4, 2024, 2:56pm UTC](https://connective.celigo.com/t/required-rule-must-have-the-respective-row-in-the-source-file/254 "2024-01-04T14:56:25Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jackharris](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/jackharris/32/6618_2.png) [@jackharris](https://connective.celigo.com/u/jackharris)\
**Post date:** [January 4, 2024, 2:56pm UTC](https://connective.celigo.com/t/required-rule-must-have-the-respective-row-in-the-source-file/254/1 "2024-01-04T14:56:25Z")

</div>

What I'm trying to do is map a flat file that comes from Koerber's KMotion product. When I try to create the rule I get a "Required rule must have the respective row in the source file" prompt and I can't find any documentation on why that is.

Here's my Sample File data

```
PARTNER MAR08SET 945ROUTE MAR08COMPANY W1BEGIN1020FMARIO CUST# 202207261777236 333941 945Q/DOMINO 1040WH Distribution Technology 1040DE MARIO CAMACHO FOODS 1040ST PROGRESSIVE FOOD SOLUTIONS LLC 91PRO8603006 1060REDIRECT CENTER 860 PICKENS INDUSTRIAL DRIVE 1070MARIETTA GA30062 1110022022072611101020220726111052202207251130H CPU CUSTOMER PICK-UP PP 20050000012010GM000072914820001722362010UC12/6 OZ CAN MARIO LARGE BLACK PITTED2020CC240 240 0 CA073651214287VN7365121428 DEC012022 2050362022120120050000022010GM000072914820001722432010UC12/5.75 OZ JAR MARIO SMT BUCKET2020CC49 49 0 CA073651117069VN7365111706 FEB072023 2050362023020720050000032010GM000072914820001722432010UC12/5.75 OZ JAR MARIO SMT BUCKET2020CC71 71 0 CA073651117069VN7365111706 FEB062023 205036202302063010360 4562.4 LB END
```

Here's where I am in my rule creation

```
{"resourcePath": "", "fileDefinition": { "name":"SE5 Flat File", "description":"856 Export for SE5", "version":1, "format":"fixed", "fixed":{ "rowsuffix": "", "rowDelimiter": "\n", "paddingChar": " " }, "rules": [{ "name":"856", "container":true, "required": true, "maxOccurrence": 1, "children": [ {"maxOccurrence":1, "required": true, "elements":[ { "name":"PARTNER", "value":"MAR08", "length":10 }] } ] } ] }}
```

Here's the full error

```
Message: Required rule must have the respective row in the source file. Path: rules[0].children[0].PARTNER for line: 1
```

---

<div class="post-metadata">

**Author:** ![tylerlamparter](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/tylerlamparter/32/9204_2.png) [@tylerlamparter](https://connective.celigo.com/u/tylerlamparter)\
**Post date:** [January 4, 2024, 8:54pm UTC](https://connective.celigo.com/t/required-rule-must-have-the-respective-row-in-the-source-file/254/2 "2024-01-04T20:54:00Z")

</div>

@jackharris this is definitely not for the faint of heart. Here is a quick stab and hopefully gets you jump started to finish the rest. [Here](https://docs.celigo.com/hc/en-us/articles/360040743071-Configure-EDI-and-fixed-width-files) is the help article where some snippet examples can be found.

 ![5301043caa20740200000001-c57aae799c40442d97867c43f9766330.png](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/e/ea5cde664b6f50f32f186edf8a9e3821869278b8.png)

```
{ "resourcePath": "", "fileDefinition": { "name": "SE5 Flat File", "description": "856 Export for SE5", "version": 1, "format": "fixed", "fixed": { "rowsuffix": "", "rowDelimiter": "\n", "paddingChar": " " }, "rules": [{ "name": "856", "container": true, "required": true, "maxOccurrence": 1, "children": [ { "maxOccurrence": 1, "required": true, "elements": [ { "name": "HEADER1", "value": "PARTNER", "length": 8 }, { "name": "PARTNER", "length": 5 }] }, { "maxOccurrence": 1, "required": true, "elements": [{ "name": "HEADER2", "value": "SET", "length": 8 }, { "name": "SET", "length": 3 }] }, { "maxOccurrence": 1, "required": true, "elements": [{ "name": "HEADER3", "value": "ROUTE", "length": 8 }, { "name": "ROUTE", "length": 5 }] }, { "maxOccurrence": 1, "required": true, "elements": [{ "name": "HEADER4", "value": "COMPANY", "length": 8 }, { "name": "COMPANY", "length": 2 }] }, { "maxOccurrence": 1, "required": true, "elements": [{ "name": "BEGIN", "value": "BEGIN", "length": 8 }] }, { "name": "1020", "maxOccurrence": 1, "required": true, "container": true, "children": [{ "maxOccurrence": 1, "required": true, "elements": [ { "name": "1020", "value": "1020", "length": 4 }, { "name": "NAME_QUALIFIER", "length": 1 }, { "name": "NAME", "length": 6 }, { "name": "CUSTOMER_ID_QUALIFIER", "length": 16 }, { "name": "CUSTOMER_ID", "length": 26 }] } ] } ] } ] }}
```

---

<div class="post-metadata">

**Author:** ![tylerlamparter](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/tylerlamparter/32/9204_2.png) [@tylerlamparter](https://connective.celigo.com/u/tylerlamparter)\
**Post date:** [January 5, 2024, 3:15pm UTC](https://connective.celigo.com/t/required-rule-must-have-the-respective-row-in-the-source-file/254/3 "2024-01-05T15:15:20Z")

</div>

@jackharris you can't have a container within the elements array. The elements array is just for fields within that row. You would need to move to under the child array.

 ![5301043caa20740200000001-54111998f17145dc87081c1f547ed8fd.png](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/6/688bc2d26c06542930491016b1ce107a8a6ac7dc.png)

---

<div class="post-metadata">

**Author:** ![jackharris](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/jackharris/32/6618_2.png) [@jackharris](https://connective.celigo.com/u/jackharris)\
**Post date:** [January 5, 2024, 3:38pm UTC](https://connective.celigo.com/t/required-rule-must-have-the-respective-row-in-the-source-file/254/4 "2024-01-05T15:38:12Z")

</div>

Thank you for all the help you've given me so far, it's been really great!

So I'm making progress in that it's no longer erroring, but the lines aren't previewing. I did what you said with the child elements (I've been trying to figure out how that worked for days now) and it worked, kinda.

 ![5301043caa20740200000001-7cc93639d7624ad1888052ad6aebd64b.png](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/a/a5eb1a0d15a7ca7843834587f3de1a682e401f44.png)

But the results don't have the Lines

```
[{ "856": [ { "1020": [ { "ReportingCode": "0", "DepositorOrderNumber": "264291", "Date": "20240103", "ShipmentID": "", "AgentShipmentID": "2090914", "PONumber": "488700", "OrderAlternateReference2": "", "systemTime": "1227", "SpecialHandlingCode": "", "ReasonCode": "", "TransactionTypeCode": "", "ActionCode": "", "LoadNumber": "002090914", "Reference1": "0244185840000", "Reference2": "ASN/INGLES", "Reference3": "MARING2871", "Reference4": "0002064", "ParcelAcct": "" }], "1040": [{ "OrganizationIDCode": "WH", "name": "Distribution Technology", "IDType": "\r" }, { "OrganizationIDCode": "DE", "name": "MARIO CAMACHO FOODS", "IDType": "\r" }, { "OrganizationIDCode": "ST", "name": "INGLES MARKETS INC", "IDType": "91", "EntityCode": "0244185840000" }], "1060": [{ "Address1": "C/O INGLES WAREHOUSE", "Address2": "2913 US HIGHWAY 70 WEST", "Address3": "", "Address4": "" }], "1070": [{ "City": "BLACK MOUNTAIN", "State": "NC", "Zip": "28711", "Country": "US", "LocationQualifier": "", "Location": "", "StateExtended": "" }], "1110": [{ "Qualifer": "02", "Date": "20240103" }, { "Qualifer": "10", "Date": "20240103" }, { "Qualifer": "52", "Date": "20231218" }], "1130": [{ "TransportationMethod": "H", "SCAC": "CPU", "Routing": "CUSTOMER PICK-UP", "MethodofPayment": "CC", "EquipmentDescriptionCode": "", "EquipmentInitial": "", "EquipmentNumber": "", "ShipmentOrderStatusCode": "", "SpecialHandlingCode": "", "CarrierChangeCode": "", "PowerUnitNumber": "", "CarryUnitNumber": "", "VesselNumber": "", "VoyageNumber": "" }], "1140": [{ "PackingCode": "PLT49", "LadingQuantity": "1556", "Weight": "16609.7", "WeightQualifier": "G", "UnitOfMeasure": "LB" }], "PARTNER": "MAR08", "SET": "ASN", "ROUTE": "MAR08", "COMPANY": "W1", "Lines": [] } ] }]
```

This is the data that I'm processing for this.

```
20050000022020CC18 18 0 CA 7365112813 SEP082025 355072 139.50 G L139.50 N L00107291480053693880 20250908 2030FRUIT SPREAD PREMIUM BLUEBERRY BLUEBERRY FRUIT SPREAD 8/007365112813                                                                                                                                                                                            
```

As you can see, it goes through the Assigned Number (2005), Item Detail (2020), and the Description (2030). It does this for an indeterminate number of lines.

So far, I've figured out that I need all three to be in a container, but I haven't figured out yet what that container of containers is supposed to look like.

---

<div class="post-metadata">

**Author:** ![jackharris](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/jackharris/32/6618_2.png) [@jackharris](https://connective.celigo.com/u/jackharris)\
**Post date:** [January 5, 2024, 3:39pm UTC](https://connective.celigo.com/t/required-rule-must-have-the-respective-row-in-the-source-file/254/5 "2024-01-05T15:39:25Z")

</div>

Here's the full "Lines" section:

```
{ "name": "Lines", "maxOccurrence": 1, "required": true, "container": true, "children": [{ "name":"AssignedNumber", "maxOccurrence": 100, "required": true, "container":true, "children":[ { "elements":[ { "name":"RecordType", "length":4, "value":"2005" }, { "name":"AssignedNumber", "length":10 }] } ] }, { "name":"ItemDetail", "maxOccurrence": 100, "required": true, "container":true, "children":[{ "elements":[ { "name": "RecordType", "value": "2020", "length": 4 }, { "name": "OrderStatus", "length": 2 }, { "name": "OrderedQuantity", "length": 17 }, { "name": "ShippedQuantity", "length": 12 }, { "name": "QuantityDifference", "length": 11 }, { "name": "UnitOfMeasureCode", "length": 2 }, { "name": "UPCCaseCode", "length": 12 }, { "name": "ItemCode", "length": 40 }, { "name": "InventoryLevel2", "length": 40 }, { "name": "InventoryLevel3", "length": 40 }, { "name": "InventoryLevel4", "length": 40 }, { "name": "GrsWeight", "length": 12 }, { "name": "GrsWeightQualifier", "length": 2 }, { "name": "GrsWeightUnitCode", "length": 1 }, { "name": "NetWeight", "length": 12 }, { "name": "NetWeightQualifier", "length": 2 }, { "name": "NetWeightUnitCode", "length": 1 }, { "name": "CaseID", "length": 48 }, { "name": "ExpiryDate", "length": 8 }, { "name": "UCC128Number", "length": 40 }, { "name": "CarrierTrackingNumber", "length": 40 }, { "name": "AlternateItemDescription", "length": 30 }] } ] }, { "name":"ItemDescription", "maxOccurrence": 100, "required": true, "container":true, "children":[{ "elements":[ { "name": "RecordType", "value": "2030", "length": 4 }, { "name": "ItemDescription", "length": 40 }, { "name": "AlternateDescription", "length": 40 }, { "name": "ExtendedDescription", "length": 40 }] } ] } ] }
```

---

<div class="post-metadata">

**Author:** ![tylerlamparter](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/tylerlamparter/32/9204_2.png) [@tylerlamparter](https://connective.celigo.com/u/tylerlamparter)\
**Post date:** [January 8, 2024, 7:03am UTC](https://connective.celigo.com/t/required-rule-must-have-the-respective-row-in-the-source-file/254/6 "2024-01-08T07:03:38Z")

</div>

@jackharris would be something like this:

Definition:

```
{ "resourcePath": "", "fileDefinition": { "_id": "65971b19a93ea53a17bb10fd", "lastModified": "2024-01-08T06:47:03.246Z", "name": "SE5 Flat File", "sandbox": false, "description": "856 Export for SE5", "version": "1", "format": "fixed", "fixed": { "rowDelimiter": "\n", "paddingChar": " " }, "rules": [{ "name": "856", "container": true, "required": true, "maxOccurrence": 1, "children": [ { "maxOccurrence": 1, "required": true, "elements": [ { "name": "HEADER1", "value": "PARTNER", "length": 8 }, { "name": "PARTNER", "length": 5 }] }, { "maxOccurrence": 1, "required": true, "elements": [{ "name": "HEADER2", "value": "SET", "length": 8 }, { "name": "SET", "length": 3 }] }, { "maxOccurrence": 1, "required": true, "elements": [{ "name": "HEADER3", "value": "ROUTE", "length": 8 }, { "name": "ROUTE", "length": 5 }] }, { "maxOccurrence": 1, "required": true, "elements": [{ "name": "HEADER4", "value": "COMPANY", "length": 8 }, { "name": "COMPANY", "length": 2 }] }, { "maxOccurrence": 1, "required": true, "elements": [{ "name": "BEGIN", "value": "BEGIN", "length": 8 }] }, { "name": "1020", "maxOccurrence": 1, "required": true, "container": true, "children": [{ "maxOccurrence": 1, "required": true, "elements": [ { "name": "1020", "value": "1020", "length": 4 }, { "name": "NAME_QUALIFIER", "length": 1 }, { "name": "NAME", "length": 6 }, { "name": "CUSTOMER_ID_QUALIFIER", "length": 16 }, { "name": "CUSTOMER_ID", "length": 26 }] } ] }, { "name": "2005", "maxOccurrence": 50, "required": true, "container": true, "children": [{ "maxOccurrence": 1, "required": true, "elements": [ { "name": "2005", "value": "2005", "length": 4 }, { "name": "AssignedNumber", "length": 6 }] }, { "name": "2010", "maxOccurrence": 50, "required": true, "container": true, "children": [{ "maxOccurrence": 1, "required": true, "elements": [ { "name": "2010", "value": "2010", "length": 4 }, { "name": "2010FIELD", "length": 300 }] } ] }, { "maxOccurrence": 1, "required": true, "elements": [{ "name": "2020", "value": "2020", "length": 4 }, { "name": "2020FIELD", "length": 200 }] }, { "maxOccurrence": 1, "required": true, "elements": [{ "name": "2050", "value": "2050", "length": 4 }, { "name": "2050FIELD", "length": 10 }] } ] } ] } ] }}
```

Input:

```
PARTNER MAR08SET 945ROUTE MAR08COMPANY W1BEGIN1020FMARIO CUST# 202207261777236 333941 945Q/DOMINO 20050000012010GM000072914820001722362010UC12/6 OZ CAN MARIO LARGE BLACK PITTED2020CC240 240 0 CA073651214287VN7365121428 DEC012022 2050362022120120050000022010GM000072914820001722432010UC12/5.75 OZ JAR MARIO SMT BUCKET2020CC49 49 0 CA073651117069VN7365111706 FEB072023 2050362023020720050000032010GM000072914820001722432010UC12/5.75 OZ JAR MARIO SMT BUCKET2020CC71 71 0 CA073651117069VN7365111706 FEB062023 20503620230206
```

Output:

```
[{ "856": [ { "1020": [ { "NAME_QUALIFIER": "F", "NAME": "MARIO", "CUSTOMER_ID_QUALIFIER": "CUST#", "CUSTOMER_ID": "202207261777236" }], "2005": [{ "2010": [ { "2010FIELD": "GM00007291482000172236\r" }, { "2010FIELD": "UC12/6 OZ CAN MARIO LARGE BLACK PITTED\r" }], "AssignedNumber": "000001", "2020FIELD": "CC240 240 0 CA073651214287VN7365121428 DEC012022", "2050FIELD": "3620221201" }, { "2010": [{ "2010FIELD": "GM00007291482000172243\r" }, { "2010FIELD": "UC12/5.75 OZ JAR MARIO SMT BUCKET\r" }], "AssignedNumber": "000002", "2020FIELD": "CC49 49 0 CA073651117069VN7365111706 FEB072023", "2050FIELD": "3620230207" }, { "2010": [{ "2010FIELD": "GM00007291482000172243\r" }, { "2010FIELD": "UC12/5.75 OZ JAR MARIO SMT BUCKET\r" }], "AssignedNumber": "000003", "2020FIELD": "CC71 71 0 CA073651117069VN7365111706 FEB062023", "2050FIELD": "3620230206" } ], "PARTNER": "MAR08", "SET": "945", "ROUTE": "MAR08", "COMPANY": "W1" } ] }]
```

---

<div class="post-metadata">

**Author:** ![jackharris](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/jackharris/32/6618_2.png) [@jackharris](https://connective.celigo.com/u/jackharris)\
**Post date:** [January 8, 2024, 2:32pm UTC](https://connective.celigo.com/t/required-rule-must-have-the-respective-row-in-the-source-file/254/7 "2024-01-08T14:32:32Z")

</div>

Do you know how to get rid of the /r?

---

<div class="post-metadata">

**Author:** ![tylerlamparter](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/tylerlamparter/32/9204_2.png) [@tylerlamparter](https://connective.celigo.com/u/tylerlamparter)\
**Post date:** [January 8, 2024, 8:17pm UTC](https://connective.celigo.com/t/required-rule-must-have-the-respective-row-in-the-source-file/254/8 "2024-01-08T20:17:12Z")

</div>

@jackharris I'm not sure how on the edi translation rules, but you could do this in a preSavePage script. See below.

 ![5301043caa20740200000001-3d91273770c1408f901b1732fb5231a7.png](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/5/5dc89cf4a9b4536a332863ed70ae7e2cd38a7066.png)

```
function preSavePage (options) { for (let d of options.data) { d = removeCarriageReturn(d); } return { data: options.data, errors: options.errors, abort: false, newErrorsAndRetryData: [] }}function removeCarriageReturn(obj) { if (typeof obj === 'object' && obj !== null) { if (Array.isArray(obj)) { obj.forEach((item, index) => { obj[index] = removeCarriageReturn(item); }); } else { Object.keys(obj).forEach((key) => { obj[key] = removeCarriageReturn(obj[key]); }); } } else if (typeof obj === 'string') { return obj.replace(/\r/g, ''); } return obj;}
```

---

<div class="post-metadata">

**Author:** ![jackharris](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/jackharris/32/6618_2.png) [@jackharris](https://connective.celigo.com/u/jackharris)\
**Post date:** [January 5, 2024, 1:18pm UTC](https://connective.celigo.com/t/required-rule-must-have-the-respective-row-in-the-source-file/254/9 "2024-01-05T13:18:21Z")

</div>

I was able to get that to work, but I ran into a new wall. Can you show me an example of a child of a child? This is what I have currently, but I'm getting an "Elements flagged as containers require at least 1 child element." error. It's weird because my child container _ **does** _ have an element.

 ![5301043caa20740200000001-155aef27ec9b4f52b4e0d4bc5a1cdb39.png](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/a/a07ad87e97ce07fd39d98a312d42c2b21cfe3cb6.png)

Here's the rules:

```
{ "resourcePath": "", "fileDefinition": { "name": "Geodis 940", "description": "Geodis 940", "version": 1, "format": "fixed", "fixed": { "rowSuffix": " \r", "rowDelimiter": "\n", "paddingChar": " " }, "rules": [{ "name": "940", "required": true, "maxOccurrence": 1, "elements": [ { "name": "HEADER", "length": 10, "value":"PARTNER" }, { "name": "CODE CLIENT", "length": 10 }] }, { "name": "ROUTE", "required": true, "maxOccurrence": 1, "elements": [{ "name": "HEADER2", "length": 10, "value":"ROUTE" }, { "name": "CODE CLIENT", "length": 10 }] }, { "name": "HEADER3", "required": true, "maxOccurrence": 1, "elements": [{ "name": "COMPANY", "length": 10, "value":"COMPANY" }, { "name": "COMPANY CODE", "length": 10 }] }, { "name": "HEADER4", "required": true, "maxOccurrence": 1, "elements": [{ "name": "SET", "length": 10, "value":"SET" }, { "name": "TRANSACTION_SET", "length": 10 }] }, { "name": "BEGIN", "required": true, "maxOccurrence": 1, "elements": [{ "name": "BEGIN", "length": 10, "value":"BEGIN" }] }, { "name": "WarehouseOrderIdentification", "required": true, "maxOccurrence": 1, "elements": [{ "name": "I940_1020_004010 1020", "length": 24, "value":"I940_1020_004010 1020" }, { "name": "OrderStatus", "length": 1 }, { "name": "OrderNumber", "length": 22 }, { "name": "PONumber", "length": 22 }, { "name": "LinkSequenceNumber", "length": 8 }, { "name": "MasterLinkNumber", "length": 22 }, { "name": "TransactionTypeCode", "length": 2 }, { "name": "ActionCode", "length": 2 }, { "name": "ParcelCarrierAccountNumber", "length": 20 }, { "name": "WarehouseCode", "length": 4 } , { "name": "ExternalLoadNumber", "length": 20 }, { "name": "ReferenceNumber", "length": 20 }] }, { "name":"1040ConsigneeName", "maxOccurrence":3, "container": true, "children":[{ "required":false, "elements":[ { "name":"I940_1040_004010 1040", "length":24, "value":"I940_1040_004010 1040" }, { "name":"IdentifierCode", "length":3 }, { "name":"Name", "length": 60 }, { "name":"IDType", "length":2 }, { "name":"EntityCode", "length":2 }] } ] }, { "name":"1060Address", "maxOccurrence":3, "container": true, "children":[{ "required":false, "elements":[ { "name":"I940_1060_004010 1060", "length":24, "value":"I940_1060_004010 1060" }, { "name":"Address1", "length":55 }, { "name":"Address2", "length": 55 }] } ] }, { "name":"1070GeographicLocation", "maxOccurrence":3, "container": true, "children":[{ "required":false, "elements":[ { "name":"I940_1070_004010 1070", "length":24, "value":"I940_1070_004010 1070" }, { "name":"City", "length":30 }, { "name":"State", "length": 2 }, { "name":"PostalZip", "length": 15 }, { "name":"Country", "length": 3 }] } ] }, { "name":"1090ReferenceIdentification", "maxOccurrence":20, "container": true, "children":[{ "required":false, "elements":[ { "name":"I940_1090_004010 1090", "length":24, "value":"I940_1090_004010 1090" }, { "name":"Qualifier", "length":2 }, { "name":"ReferenceID", "length": 30 }, { "name":"ReferenceDescription", "length": 45 }, { "name":"Date", "length": 8 }] } ] }, { "name":"1110DateAndTime", "maxOccurrence":3, "container": true, "children":[{ "required":false, "elements":[ { "name":"I940_1110_004010 1110", "length":24, "value":"I940_1110_004010 1110" }, { "name":"DateQualifier", "length":2 }, { "name":"Date", "length": 8 }, { "name":"TimeQualifier", "length": 2 }, { "name":"Time", "length": 8 }] } ] }, { "name":"1120NoteSpecialInstruction", "maxOccurrence":50, "container": true, "children":[{ "required":false, "elements":[ { "name":"I940_1120_004010 1120", "length":24, "value":"I940_1120_004010 1120" }, { "name":"Code", "length":3 }, { "name":"Remark", "length": 80 }] } ] }, { "name": "1140WarehouseCarrierInformation", "required": true, "maxOccurrence": 1, "elements": [{ "name": "I940_1140_004010 1140", "length": 24, "value":"I940_1140_004010 1140" }, { "name": "MethodOfPayment", "length": 2 }, { "name": "TransportationMethod(W6602)", "length": 2 }, { "name": "PalletExchangeCode", "length": 1 }, { "name": "UnitLoadOptionCode", "length": 2 }, { "name": "CarrierName", "length": 35 }, { "name": "FOBPointCode", "length": 2 }, { "name": "FOBPoint", "length": 30 }, { "name": "CODMethodOfPaymentCode", "length": 1 }, { "name": "Amount", "length": 17 }, { "name": "SCAC", "length": 4 }] }, { "name":"AssignedNumbers", "maxOccurrence":5000, "container": true, "children":[{ "required":false, "elements":[ { "name":"I940_2005_004010 2005", "length":24, "value":"I940_2005_004010 2005" }, { "name":"AssignedNumber", "length":9 }, { "name":"Remark", "length": 80 }, { "name":"AssignedNumbers", "maxOccurrence":5000, "container": true, "children":[ { "required":false, "elements":[ { "name":"I940_2005_004010 2005", "length":24, "value":"I940_2005_004010 2005" }, { "name":"AssignedNumber", "length":9 }, { "name":"Remark", "length": 80 }] } ] } ] } ] } ] }}
```

And here's my sample file.

```
PARTNER USC02 ROUTE USC02 COMPANY W1SET 940BEGIN I940_1020_004010 1020N0086617186 355840 I940_1040_004010 1040SF DW12 93DW1U I940_1040_004010 1040CA Collect Customer Pick Up I940_1040_004010 1040ST Harris-Teeter, Inc. 930000004586 I940_1060_004010 1060200 Distribution Drive I940_1070_004010 1070Greensboro NC27410 US I940_1090_004010 1090OQ 0003100737 I940_1090_004010 1090AG 0000000000 I940_1090_004010 1090SI 0006317832 I940_1110_004010 11100220240112 I940_1120_004010 1120INThtscheduling@harristeeter.com I940_1140_004010 1140CCH Collect Customer Pick Up CPU I940_2005_004010 20050 I940_2020_004010 2020189 BA VN813850 I940_2030_004010 203020/2 HARRIS TEETER FINE GRAN -CHEP I940_2040_004010 2040LI 000010 I940_2005_004010 20051 I940_2020_004010 2020350 BA VN816840 I940_2030_004010 20304/10 HARRIS TEETER FG - CHEP 70/PLT I940_2040_004010 2040LI 000020 I940_2005_004010 20052 I940_2020_004010 2020504 CA VN816670 I940_2030_004010 203012/2 HARRIS TEETER PWD - CHEP 63/PLT I940_2040_004010 2040LI 000030 I940_2005_004010 20053 I940_2020_004010 2020280 CA VN816693 I940_2030_004010 203012/2 HARRIS TEETER LT BROWN 70/PLT- CHEP I940_2040_004010 2040LI 000040 END
```

---

<div class="post-metadata">

**Author:** ![jackharris](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/jackharris/32/6618_2.png) [@jackharris](https://connective.celigo.com/u/jackharris)\
**Post date:** [January 5, 2024, 5:18pm UTC](https://connective.celigo.com/t/required-rule-must-have-the-respective-row-in-the-source-file/254/10 "2024-01-05T17:18:49Z")

</div>

I got it most of the way there with the below, but it's not iterating and I'm not sure what I'm missing.

Rule:

```
{ "name": "2005", "required": false, "container": true, "children": [{ "required": true, "elements": [ { "name": "RecordType", "value": "2005", "length": 4 }, { "name": "AssignedNumber", "length": 10 }], "name":"2020", "children":[{ "elements": [ { "name":"RecordType", "value":"2020", "length":4 }, { "name":"Quantity", "length":17 }], "children":[{ "elements": [ { "name":"RecordType", "length":4, "value":2030 }, { "name":"Description", "length":40 }] } ] } ] }
```

Sample:

```
20050000032020CC170 170 0 CA 7365121422 JAN242026 341286 2210.00 G L2210.00 N L00107291480053693897 20260124 2030911 12/6 MEDIUM PITTED RIPE OLIVES 12/6 OZ CAN MARIO MEDIUM BLACK PITTED 12/007365121422 20050000042020CC100 100 0 CA 7365121422 JAN242026 341303 1300.00 G L1300.00 N L00107291480053693903 20260124 2030911 12/6 MEDIUM PITTED RIPE OLIVES 12/6 OZ CAN MARIO MEDIUM BLACK PITTED 12/007365121422 20050000052020CC47 47 0 CA 7365111746 DEC212025 353780 564.00 G L564.00 N L00107291480053693910 20251221 203012/6 OZ JAR MARIO SALAD 12/6 OZ JAR MARIO SALAD 12/007365111746 20050000062020CC15 15 0 CA 7365111746 DEC212025 353780 180.00 G L180.00 N L00107291480053693910 20251221 203012/6 OZ JAR MARIO SALAD 12/6 OZ JAR MARIO SALAD 12/007365111746 20050000072020CC5 5 0 CA 7365111746 DEC212025 353780 60.00 G L60.00 N L00107291480053693910 20251221 203012/6 OZ JAR MARIO SALAD 12/6 OZ JAR MARIO SALAD 12/007365111746 20050000082020CC5 5 0 CA 7365111746 DEC212025 353780 60.00 G L60.00 N L00107291480053693910 20251221 203012/6 OZ JAR MARIO SALAD 12/6 OZ JAR MARIO SALAD 12/007365111746 20050000092020CC57 57 0 CA 7365111710-A DEC222025 339563 1055.64 G L1055.64 N L00107291480053693927 20251222 2030GREEN OLIVES STF W/PIMIENTO STUFFED WITH PIMIENTO 6/007365111710 20050000102020CC3 3 0 CA 7365111710-A DEC222025 339564 55.56 G L55.56 N L00107291480053693927 20251222 2030GREEN OLIVES STF W/PIMIENTO STUFFED WITH PIMIENTO 6/007365111710 20050000112020CC45 45 0 CA 7365121440-DEHK 030226 345446 540.00 G L540.00 N L00107291480053693934 20260302 2030921 12/6 EXLARGE PITTED RIPE OLIVES 12/6 OZ TIN TRAY MARIO EX LG BLACK PITTED 12/007365121440 20050000122020CC38 38 0 CA0736511613387365116133 MAY252026 355950 293.36 G L293.36 N L00107291480053693941 20260525 2030GREEN OLIVES STUFFED WITH REAL PIMIENTO. OLIVES 6/007365116133 20050000132020CC153 153 0 CA 7365111706 NOV282025 339027 1839.06 G L1839.06 N L00107291480053693958 20251128 2030133 12/5.75OZ STUFFED GREEN OLIVES W/PIMSTUFFED GREEN OLIVE STUFFED W PIMIENTO 12/007365111706 20050000142020CC19 19 0 CA 7365111706 NOV282025 339026 228.38 G L228.38 N L00107291480053693965 20251128 2030133 12/5.75OZ STUFFED GREEN OLIVES W/PIMSTUFFED GREEN OLIVE STUFFED W PIMIENTO 12/007365111706 20050000152020CC32 32 0 CA 7365111706 NOV282025 339040 384.64 G L384.64 N L00107291480053693965 20251128 2030133 12/5.75OZ STUFFED GREEN OLIVES W/PIMSTUFFED GREEN OLIVE STUFFED W PIMIENTO 12/007365111706 20050000162020CC34 34 0 CA0736511613147365179702 SEP262025 356137 241.40 G L241.40 N L00107291480053693972 20250926 2030GREEN CASTLEVELTRANO OLIVES 160/180 PITTED GREEN CASTELEVELTRANO OLIVES 6/007365179702 20050000172020CC34 34 0 CA0736511613147365179702 SEP262025 356138 241.40 G L241.40 N L00107291480053693972 20250926 2030GREEN CASTLEVELTRANO OLIVES 160/180 PITTED GREEN CASTELEVELTRANO OLIVES 6/007365179702 20050000182020CC38 38 0 CA 7365116132 JUN222025 351533 300.20 G L300.20 N L00107291480053693989 20250622 2030GREEN OLIVES STUFFED WITH FETA CHEESE 6/007365116132 20050000192020CC207 207 0 CA 7365121405 DEC192025 339537 1925.10 G L1925.10 N L00107291480053693996 20251219 2030980 24/2.25 SLICED RIPE OLIVES TRAY PACK24/2.25 OZ CAN MARIO SLICED BLACK OLIVE TRAY PK 24/007365121405 20050000202020CC207 207 0 CA 7365121405 DEC192025 339538 1925.10 G L1925.10 N L00107291480053694009 20251219 2030980 24/2.25 SLICED RIPE OLIVES TRAY PACK24/2.25 OZ CAN MARIO SLICED BLACK OLIVE TRAY PK 24/007365121405 20050000212020CC26 26 0 CA 7365121405 DEC192025 339524 241.80 G L241.80 N L00107291480053694016 20251219 2030980 24/2.25 SLICED RIPE OLIVES TRAY PACK24/2.25 OZ CAN MARIO SLICED BLACK OLIVE TRAY PK 24/007365121405 20050000222020CC16 16 0 CA 7365121428-WA DEC232025 342185 208.00 G L208.00 N L00107291480053694023 20251223 2030916 12/6 LARGE PITTED RIPE OLIVES 12/6 OZ CAN MARIO LARGE BLACK PITTED 12/007365121428 20050000232020CC74 74 0 CA 7365121428-WA DEC232025 342190 962.00 G L962.00 N L00107291480053694023 20251223 2030916 12/6 LARGE PITTED RIPE OLIVES 12/6 OZ CAN MARIO LARGE BLACK PITTED 12/007365121428 20050000242020CC84 84 0 CA 7365112877 SEP112025 356597 653.52 G L653.52 N L00107291480053694030 20250911 2030FRUIT SPREAD PREM 8/GL TRY PK BLACKBERRYBLACKBERRY FRUIT SPREAD 8/007365112877 20050000252020CC42 42 0 CA 7365112869 DEC192024 339302 326.76 G L326.76 N L00107291480053694047 20241219 2030FRUIT SPREAD PREM 8/GL TRY PK MIXD FRUITMIXED FRUIT FRUIT SPREAD 8/007365112869 20050000262020CC42 42 0 CA 7365112864 SEP132025 356607 325.50 G L325.50 N L00107291480053694054 20250913 2030FRUIT SPREAD PREMIUM RASPBERRY RASPBERRY FRUIT SPREAD 8/007365112864
```

Parsed Output (I'm also getting the "/r" again and haven't figured out how to get rid of it):

```
"2005": [{ "AssignedNumber": "000001\r" }, { "Quantity": "CC45" }, { "Description": "FRUIT SPREAD PREMIUM BLUEBERRY" }],
```

I'm expecting to see more 2005 iterations.
