5 Replies Latest reply on Apr 4, 2016 7:37 AM by steveoh

    Disecting entire line from Text Field

    steveoh

      Hey Again

       

      So I'm working on a solution that requires an ability to read dissected text from a field.  The line number is variable, but the text I want always follows a known block of text, such as "Example:".  I had figured using the left/right command, but the text needed isn't always the same length or on the same line.

       

      In one text field it could be on the 10th line, another it could be on the 4th etc.

       

      Is it possible to do something like:

       

      Right ( Field ;( something to denote the end of that line ) - ( position of "example:" ) ; -1 )

       

      Thanks in advance

        • 1. Re: Disecting entire line from Text Field
          dtcgnet

          Provide an actual example of what's in the field for a couple of records.

           

          As for the text you want, after the known block of text, do you want ALL of the remaining text? Or all of the text up to some other point?

           

          As for a formula, I'd probably use a Let statement because it'll be easier to see what you're doing.

           

          Let (

          [

          KnownText = "Example: " ;

          FieldToUse = TableName::FieldName

          LengthOfField = Length ( FieldToUse ) ;

          LengthOfKnownText = Length ( KnownText ) ;

          EndOfKnownText = Position ( FieldToUse ; KnownText ; 1 ; 1 ) + LengthOfKnownText - 1

          ] ;

           

           

          Right ( FieldToUse ; LengthOfField - EndOfKnownText )

          )

          • 2. Re: Disecting entire line from Text Field
            steveoh

            alright, so basically this has to do with emailing.  I have a plugin that retrieves mail (mailit) and I wanted to set up something that picks up when messages return.  There's a sample message below,

             

            I've censored any sensitive material (with [ ]), this is to be used to send information to our customers about their account and on rare occasion the email provided is not accurate.  My intention is to grab the information in To: [Recipient] and then place a note on their account that the message returned so that when they come in we can update their contact information.

             

            Because this is sent over SMTP, the return message looks slightly different for some @domain.com email addresses, so would prefer not to have it look on the, in this case, 5th line.  Sample Message:

             

                      Message could not be delivered

             

                      Original Message:

                      From: [My email]

                      To: [Recipient]

                      Subject: [Subject]

                      Date:  Tue, 29 Mar 2016 16:32:51 +0000

            • 3. Re: Disecting entire line from Text Field
              erolst

              Not sure if this is what you want, but you can try:

               

              Let ( [

                identifier = "To: " ;

                len = Length ( identifier ) ;

                pos = Position ( yourMailBlock ; identifier ; 1 ; 1 ) ;

                retCount = ValueCount ( Left ( yourMailBlock ; pos ) ) ;

                theLine = GetValue ( yourMailBlock ; retCount )

                ] ;

                Middle ( theLine ; len +1 ; Length ( theLine ) - len )

              )

              • 4. Re: Disecting entire line from Text Field
                dtcgnet

                Gotcha. So you are trying to isolate what's in "[Recipient]", then you'd use that to find the appropriate customer in your database and do something? And if your database didn't have a customer whose email matched with what you had, you'd do something else?

                 

                Let (

                [

                FieldToUse = TableName::FieldName ;

                 

                ToText = "To: " ;

                ToText_Length = Length ( ToText ) ;

                StartOf_ToText = Position ( FieldToUse ; ToText ; 1 ; 1 ) ;

                EndOfToText = Position ( FieldToUse ; ToText ; 1 ; 1 ) + ToText_Length ;


                SubjectText = "Subject: " ;

                StartOf_SubjectText = Position ( FieldToUse ; SubjectText ; 1 ; 1 ) ;

                ] ;

                 

                Trim ( Middle ( FieldToUse ; StartOf_ToText + ToText_Length ; StartOf_SubjectText - EndOfToText - 1 ) )

                )

                • 5. Re: Disecting entire line from Text Field
                  steveoh

                  Sorry for the delayed reply, had pressing matters to resolve before I could use your proposed solution.  It worked like a charm!  Thanks for your help!

                   

                  MINOR NOTE:  I did have to remove the " " from "To: " for it to work