EDI.Net icon indicating copy to clipboard operation
EDI.Net copied to clipboard

v1.9.17 suddenly adds empty N1 segment to EDI files.

Open codewg opened this issue 4 years ago • 2 comments

I was using v1.9.12, since then I have downgraded and upgrade 1 version at a time to verify which version introducted this. It is v1.9.17, I have upgraded to 1.9.16 and up to that version the EDI comes out the same. As soon as I upgrade to v1.9.17 I get an extra unwanted and empty N1 segement, IE

N1OTORIGIN
N1*\ *** This is suddenly here, only change was in upgrading libraries. Unable to determine where this is coming from. All the members of Origin appear to be NULL, expect CITY and SATE members. N4CITYKS
N1DTDESTINATION
N3STREET ADDRESS
N4
CITYKS
FGS
RMKXXXXXX\

I can't share actual EDI, would probably take too much to sanitize one. Below is the pertainent class definition and encompassing class.


         // Segment(s) are include as an list (ie a loop)

         // Name Loop (N1)
         public List<NameSegment> NameSegments { get; set; }

         // Location Loop (N4)
         public List<LocationSegment> LocationSegments { get; set; }

         // Form Group Segment Loop (FGS)
         public List<FormGroupSegment> FormGroupSegments { get; set; }


         // Related/Relevant Class Segment Declarations
         [EdiSegment]
         public class LocationSegment
         {
            [EdiCondition("OT", Path = "N1/0")]
            public OriginSegment Origin { get; set; }

            [EdiCondition("DT", Path = "N1/0")]
            public DestinationSegment Destination { get; set; }
         }

         [EdiSegmentGroup("N1")]
         public class OriginSegment
         {
            [EdiValue("X(2)", Path = "N1/0", Description = "N101 - Name Qualifier")]
            public string EntityId { get; set; }

            [EdiValue("X(35)", Path = "N1/1", Description = "N102 - Name")]
            public string Name { get; set; }

            [EdiValue("X(2)", Path = "N1/2", Description = "N103 - Id Code Qualifier")]
            public string IdCodeQualifier { get; set; }

            [EdiValue("X(9)", Path = "N1/3", Description = "N104 - Id Code"),
             EdiCondition("TC", Path ="N1/2")]
            public string IdCode { get; set; }

            [EdiValue("X(18)", Path = "N4/0", Description = "N401 - City Name")/*,
             EdiCondition("TC", CheckFor = EdiConditionCheckType.NotEqual, Path = "N1/2")*/]
            public string CityName { get; set; }

            [EdiValue("X(2)", Path = "N4/1", Description = "N401 - State")/*,
             EdiCondition("TC", CheckFor = EdiConditionCheckType.NotEqual, Path = "N1/2")*/]
            public string State { get; set; }
         }

         [EdiSegmentGroup("N1")]
         public class DestinationSegment
         {
            [EdiValue("X(2)", Path = "N1/0", Description = "N101 - Name Qualifier")]
            public string EntityId { get; set; }

            [EdiValue("X(35)", Path = "N1/1", Description = "N102 - Name")]
            public string Name { get; set; }

            [EdiValue("X(2)", Path = "N1/2", Description = "N103 - Id Code Qualifier")]
            public string IdCodeQualifier { get; set; }

            [EdiValue("X(9)", Path = "N1/3", Description = "N104 - Id Code")]
            public string IdCode { get; set; }

            [EdiValue("X(35)", Path = "N3/0", Description = "N301 - First Street Address")]
            public string FirstStreeAddress { get; set; }

            [EdiValue("X(35)", Path = "N3/1", Description = "N302 - Second Street Address")]
            public string SecondStreeAddress { get; set; }

            [EdiValue("X(18)", Path = "N4/0", Description = "N401 - City Name")]
            public string CityName { get; set; }

            [EdiValue("X(2)", Path = "N4/1", Description = "N401 - State")]
            public string State { get; set; }
         }

I hope that is enough of an example/explanation of what I am seeing. Let me know if you need anything else.

codewg avatar Jan 02 '21 23:01 codewg

I got it to work with v1.9.17, but I had to comment out the EdiCondition("TC", Path ="N1/2") on N1/3 in OriginSegment class. I'm not sure that the condition needs to be there, but generally I don't put things like that in place, unless I run into a situation where it applies.. Could still be a bug, seems like v1.9.12-1.9.16 handled this EdiCondition differently (would seem correctly, as the N1/2 is OT not TC in this case.

codewg avatar Jan 02 '21 23:01 codewg

Hi @codewg and thanks for your interest in EDI.Net.

On first look it seems you have some misconfigured properties.

  1. EdiSegment Attribute can only be used in a container class that hosts only EdiValue properties of the same segment tag (for example N1). So marking the LocationSegment as such would be wrong.
  2. The EdiCondition segment cannot be used to discriminate databinding to Value properties (Component). It is used to discriminate different types of containers that cannot be distinguished only by their name tag (EdiGroup/EdiMessage/EdiSegment/EdiElement) and a decision needs to be made using a component value from withing the segment itself. Thus any combination of EdiValue & EdiCondition would be invalid. Check an example here

cleftheris avatar Jan 13 '21 06:01 cleftheris