10 Replies Latest reply on Oct 19, 2017 3:50 AM by Marcell Alzate

    Carriage Return is not getting identified in REPLACE function

      Share This:

      Hi,

       

      I want to replace Carriage Return (New line) character with ";". Therefore, I written the REPLACE function in Filter with Set Field Action.

      REPLACE($Sring$,"

      ",";")

       

      But this is not changing the end of the line/s with ;

       

      I am using ARS 7.5 Patch 004 and BMC Remedy Developer Studio Version: 7.5.00 Patch 004.

       

      Please help me to resolve this issue.

       

      Thanks,

      Anirudha

        • 1. Re: Carriage Return is not getting identified in REPLACE function
          Misi Mladoniczky

          Hi,

           

          This is always tricky.

           

          Sometimes a return is built of two characters CR+LF, and sometimes of one LF.

          There is also a problem with some databases, so when you type "

          ", it adds a space in the beginning (if I remember right). In this case tou need to amend your replace as follows:

          REPLAE($String$, RIGHT("

          ", 1), ";")

           

                  Best Regards - Misi, RRR AB, http://rrr.se

          1 of 1 people found this helpful
          • 2. Re: Carriage Return is not getting identified in REPLACE function
            Laurent Matheo

            Too bad we can't use a function like CHAR or ASC in Remedy...

            I wonder if it's possible to do this, to generate a CR, a LF in a text editor and copy / paste it into a REPLACE?

             

            First action:

            Generate an ASCII character 10 in noteplad++ and copy paste:

            REPLACE($Sring$,"

            ",";")

             

             

            Second action action:

            Generate an ASCII character 13 in noteplad++ and copy paste:

            REPLACE($Sring$,"

            ",";")

             

            I managed to do it in Ultraedit since it has a hexadecimal editor in it, but can't try on ARS right now...

            09-08-2012 15-47-40.png

             

            Else perhaps using this?

            https://communities.bmc.com/communities/message/258870#258870

             

             

            Or doing like Misi said... Since CR+LF (\r\n) is actually two characters, if it's working like C++ you could try this to "delete" CR and LF in two actions:

            For \r:

            REPLACE($String$, LEFT("

            ", 1), ";")

             

            For \n:

            REPLACE($String$, RIGHT("

            ", 1), ";")

            • 3. Re: Carriage Return is not getting identified in REPLACE function
              Misi Mladoniczky

              Hi,

               

              This might be a good idea Laurent.

               

              And will also need to remove any space that might have been put there by the database when you enter only "CRLF". The result might be "SpaceCRLF"

               

              And you can still do it in a single action:

               

              REPLACE(REPLACE($String$, LEFT(REPLACE("

              ", " ", ""), 1), ""), RIGHT(REPLACE("

              ", " ", ""), 1), ";")

               

              Pretty straight forward, right

               

              The above should in theory always give you a ";" instead of any combination of CR/LF. At least if you entered a CR+LF to start with...

               

                      Best Regards - Misi, RRR AB, http://rrr.se

              1 of 1 people found this helpful
              • 5. Re: Carriage Return is not getting identified in REPLACE function
                Saroj Sahu

                - Open ALink, set fields action

                - Select field on left side

                - Open expression editor for Right side assignment

                - Select , functions , replace. It will show u 3 params

                - Param 1: string - select the source field. e.g. Short descriotion

                - Param 2: find - Open another expression builder for this param, on the right side text box, type ", hit enter, type " and click ok

                - param 3: replace: Open another expression builder for this param, on the right side text box, type ";" and click ok

                - Click add function and close the expression editor

                - Save the ALink

                - I have tested this and it works fine

                 

                Just in case you want AR generated code, below is how it goes:

                Form: TST:FORM

                Fields on form:
                     Data (536870913): main field with mutiple lines

                     Parsed Data (536870914): field on form that will store ; inplace of new-line character

                Attached is the AL def file (sample). Modify the AL as per your form and fields.

                • 6. Re: Carriage Return is not getting identified in REPLACE function
                  Misi Mladoniczky

                  Hi Saroj,

                   

                  All this was apparently known by Anirudha even before he asked the question.

                   

                  We are on the next level of analysis here, where we are discussing one or two characters in a "return", and the potentally added space if you just create a string with only CR/LF and store it in the database.

                   

                          Best Regards - Misi, RRR AB, http://rrr.se

                  • 7. Re: Carriage Return is not getting identified in REPLACE function
                    Saroj Sahu

                    Thanks Misi. My point was, if a new line is added in the Replace function in the expression editor, it should use/generate appropriate char-codes. If AR does not do so, I would think of this as a possible AR defect and raise it to BMC and let this issue be resolved in the core product itself, instead of trying out many work-arounds.

                    • 8. Re: Carriage Return is not getting identified in REPLACE function
                      Misi Mladoniczky

                      Hi,

                       

                      Both NL and CR+NL are correct. It depends on your client. The system generating the data is responsible, and it can sometimes be hard to control this for an average user.

                       

                      The "space" added by the database apparently is not something that BMC can control either, at least this is what Doug Mueller has explained to med way back in ancient history-

                       

                      So no, this is not a bug in the AR System. It sould be nice to better be able to control what you type in strings though. As you can do in most development tools. For example "\r\n" as you would write it in a majority of tools. So what we can do is to submit an RFE to change Dev Studio in that way.

                       

                              Best Regards - Misi, RRR AB, http://rrr.se

                      • 9. Re: Carriage Return is not getting identified in REPLACE function
                        Marcell Alzate

                        Hi Misi,

                         

                        Not as straight forward as it looks

                        .. I haven't been able to find a way to send multi-line text to the vbs script

                        I'm trying to use this replacement to be able to send the output to a vbs script where it only receives the very first line.

                        My idea was to put multiple chars there instead of the CR/LF, and them replace them back to CR/LF in the script.

                        But I'm not even getting the ";" when using the replacement suggested.

                         

                        any idea?

                        • 10. Re: Carriage Return is not getting identified in REPLACE function
                          Marcell Alzate

                          Solve by putting the needed chars (#%&) in all the replace function:

                           

                          REPLACE(REPLACE($Tmp_HTML_Text$, LEFT(REPLACE("

                          ", " ", "#%&"), 1), "#%&"), RIGHT(REPLACE("

                          ", " ", "#%&"), 1), "#%&")

                           

                          It is working.. then in the vbs script i have something like:

                          Replace(string, "#%&", vbLf)

                           

                          do you see any problems with this approach? I'm trying to see if someone sees something I might be missing, since testing is ok

                           

                          BTW.. version where this is working: BMC Remedy AR System 9.1.03.001 201708171714