2 Replies Latest reply on Mar 7, 2019 5:42 PM by inuser476294

    Trouble with trailing new lines

    New Member

      Hello. I am pulling text data from a field in Microsoft Dynamics 365 and trying to detect any trailing line feed/carriage returns but I can't seem to detect it in my expressions.  The only thing I can think of is that it is html encoded, which I'll give a shot at after I post this.


      Here's some expressions I was trying:

      And here expression "EXP_NotesTrimmed" is where I tried to find both CHR(10) and CHR(13), but both failed. "EXP_NotesLastChar" is grabbing the last char to out to a csv, which resulted in a new line output. The last 2 expressions are returning false(0) proving that the last character of the string is neither a CHR(10) nor CHR(13)


      I used the following to find CHR(10) and CHR(13) for line feed and carraige return:


      HOW TO: Remove newline characters using an expression


      Thanks for any help, now I'll go check for a possible html encoded version.

        • 1. Re: Trouble with trailing new lines
          Yogi S Support Moderators


          the syntax of substr is SUBSTR(<fieldname>,start_pos, length).

          since you are providing length = EXP_LengthNotes (which is length of whole string anyways), you are selecting 2 characters not 1 character.


          can you try changing your substr condition for expression field EXP_NotesTrimmed to something like this

          IIF(SUBSTR(mmc_PayrollNotesML, EXP_LengthNotes, 1 )=CHR(13), SUBSTR(mmc_PayrollNotesML,0,EXP_LengthNotes-1), mmc_PayrollNotesML)


          you might need to tweak a bit for carriage return and line feed.

          • 2. Re: Trouble with trailing new lines
            New Member

            That was very close Yogi. You maybe have even meant to correct me like this -



            Apparently, it was failing because I was requesting more than one character(EXP_LengthNotes), but seems like could be a bug, since there is only 1 remaining character in the string. Thanks anyways!