Skip to content

Optional Tags in Loop #47

@ChickenBone

Description

@ChickenBone

Hi there!

I am running into an issue I hope others have encountered. I am trying to generate a X12 4010, 214 document and am running into a roadblock with the N1Loop.

In this loop there is

N1*
N2
N3
N4

The issue comes that only N1 is required and in most cases the N1Loop will have all of them N1-4 for most of them but then one of the segments in the loop with only have N1, is there any way to achieve this? I cannot seem to figure out how to have a element not be there if the provided data is not there. The closest I've gotten ( below ) just provides a empty N2-4 with the contents like N4***~

where: 'N3' seems to "sortof" work

    {
            tag: 'N3',
            elements: [
                "{{ input.N1Loop | map: 'N3.AddressInformation_01' | in_loop | where: 'N3' }}",
                "{{ input.N1Loop | map: 'N3.AddressInformation_02' | in_loop | where: 'N3' }}",

            ],
        },

The Whole Tamale

   {
            tag: 'N1',
            elements: [
                "{{ input.N1Loop | map: 'N1.EntityIdentifierCode_01' | in_loop }}",
                "{{ input.N1Loop | map: 'N1.Name_02' | in_loop }}",
            ],
            loopStart: true,
            loopLength: "{{ input.N1Loop | size }}",
        },
        {
            tag: 'N3',
            elements: [
                "{{ input.N1Loop | map: 'N3.AddressInformation_01' | in_loop | where: 'N3' }}",
                "{{ input.N1Loop | map: 'N3.AddressInformation_02' | in_loop | where: 'N3' }}",

            ],
        },
        {
            tag: 'N4',
            elements: [
                "{{ input.N1Loop | map: 'N4.CityName_01' | in_loop }}",
                "{{ input.N1Loop | map: 'N4.StateorProvinceCode_02' | in_loop }}",
                "{{ input.N1Loop | map: 'N4.PostalCode_03' | in_loop }}",
            ],
            loopEnd: true,
        },

Thank you in advanced, Also going to dig into the js-edi package and see if there is something I can maybe use? Thank you so much for your work on these packages, this is a relatively small issue in the scope of EDI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions