6 Replies Latest reply on Nov 18, 2016 6:33 AM by alquimby

    Which Character is Missing??

    osensnolf

      Willing to send a few dollars your way via PayPal for a solution.

       

      My developer created the following script for me.  In short, the script looks at a list of words (keywords) and determines if the word appears within certain fields (such as Company, Description, etc).  It works as designed but now I want it to be able to look within a URL and email.

       

      My original list of words looks like this..

      attorney

      lawyer

      "law office"

       

       

      My new list of words for email and URL looks like this..

      *attorney*

      *lawyer*

      *lawoffice*

       

      I think the script is broke because I am using * and because the new list of keywords are within words - not starting at the beginning of the word.

       

      What simple tweak do I need to revise to make this work?

       

      Thanks in advance. 

       

      Set Error Capture [ On ]

      Set Variable [ $Script_Overide ; Value:1 ]

      If [ Get ( ScriptParameter ) = "Manual" ]

      Set Field [ Contacts::MatchingKeywords ; Let([

      // Source Keywords

      ListA = List(Contacts|KEYWORDS||gServiceSelector::Keywords) ;

      ListA = Substitute ( ListA ; "\"" ; "" ) ; // remove "quotes"

      // Derived Keywords

      ListB = Contacts::cKeywordSearchKeyNoServices;

      EqualsWords = "=" & Substitute ( ListB ; [ "¶" ; " "] ; [ "asdf " ; " " ] ; [ " " ; " " ] ;[" " ; "¶="] ) ;

      ListB = FactorWords ( ListB ) ;

      ListB = FactorList ( ListB ) ;

      ListB = List( EqualsWords ; ListB ) ;

      ~list = FilterValues ( ListA ; ListB ) ;

      ~list = Substitute ( ~list ; ["¶¶" ; "¶"] ;["¶" ; ", " ] )

      ];

      ~list

      ) ]

      Commit Records/Requests

      [ Skip data entry validation; No dialog ]

      Exit Script [ ]

      End If

      Go to Layout [ “Contacts List” (Contacts) ]

      Refresh Window

      Perform Find [ Specified Find Requests: Find Records ; Criteria: Contacts::Service : “Inactive” AND Contacts::MatchingKeywords :

      “Refresh” ]

      [ Restore ]

      If [ Get ( LastError ) ]

      Show Custom Dialog [ Title: "Done"; Message: "There are no records that need updating."; Default Button: “OK”, Commit: “Yes” ]

      Exit Script [ ]

      End If

      Replace Field Contents [ Contacts::MatchingKeywords ; Replace with calculation: Let([

      // Source Keywords

      ListA = List(Contacts|KEYWORDS||gServiceSelector::Keywords) ;

      ListA = Substitute ( ListA ; "\"" ; "" ) ; // remove "quotes"

      // Derived Keywords

      ListB = Contacts::cKeywordSearchKeyNoServices;

      EqualsWords = "=" & Substitute ( ListB ; [ "¶" ; " "] ; [ "asdf " ; " " ] ; [ " " ; " " ] ;[" " ; "¶="] ) ;

      ListB = FactorWords ( ListB ) ;

      ListB = FactorList ( ListB ) ;

      ListB = List( EqualsWords ; ListB ) ;

      ~list = FilterValues ( ListA ; ListB ) ;

      ~list = Substitute ( ~list ; ["¶¶" ; "¶"] ;["¶" ; ", " ] )

       

      ];

      ~list

      ) ]

      [ No dialog ]

      Show Custom Dialog [ Title: "Done"; Message: "All records are updated."; Default Button: “OK”, Commit: “Yes” ]

        • 1. Re: Which Character is Missing??
          philmodjunk

          There is a tremendous amount of missing information there--including calls to custom functions that do unknown changes to the data passed to them. The almost total lack of comments make it especially difficult and not being able to see the data and the data model on which this script acts makes the whole process nearly impossible to figure out.

           

          I suggest, that if you really want to pay for someone's services, that you do exactly that and share the file with them along with being available to answer questions about the file.

          • 2. Re: Which Character is Missing??
            Vaughan

            osensnolf wrote:

             

            ... the new list of keywords are within words - not starting at the beginning of the word.

             

             

             

            Searching for whole keywords is a very different process to pattern-matching partial words. In short, there won't be a simple tweak.

            • 3. Re: Which Character is Missing??
              osensnolf

              Not sure if it matters, but the current script searches for partial matches (starting at the beginning of a word).

               

              Account finds Accounting but does not find TheAccountant

              Pet finds Petting but not carPETing

               

              With the revision, I want...

               

              *account* to find TheAccountant and SamsAccountingService

              *pet* to find carpeting and MikesCarpetStore

               

              My assumption was that there was something in the original script telling it to start at the beginning of the word and that simply telling it to look anywhere within the word would be valid.  Guess that is not the case...

              • 4. Re: Which Character is Missing??
                keywords

                Two points:

                1.     You are using the * as a wildcard entry, as you would in a Find. However, within a calculation FM may interpret * as a multiplier, and obviously produce a different outcome. I can't really make sense of your script as presented, but if it is your intention to be performing Finds (which is what it sounds like) then change your script to the more explicit format most developers recommend:

                Enter Find Mode

                Set Field [ tableName::fieldName ; "*accountOrWhatever*" ] // NOTE: * is here part of a text expression, so can't be misinterpreted

                Perform Find [ ]

                This is much easier to parse and modify if needed, not to mention being much easier for others to help you with.

                 

                2.     You will need to fully understand how Find searches work, and may need to input more that one search criterion (another advantage of the script syntax suggested above). For example, the * both before and after, as in your examples, may find different results to only before, or only after.

                • 5. Re: Which Character is Missing??
                  osensnolf

                  I'll pass this along to someone else who better understands this.  I'm not a developer - just FM user so I think there are limitations I have.  Thank you.

                  • 6. Re: Which Character is Missing??
                    alquimby

                           I found your subject here intriguing, but the script is a little bit too daunting for me, so I tried something different. In the attached, there is a PatternCount calculation test field for each of the fields being queried. The test field is to the immediate right of the field it is testing. (This is best demonstrated in List view.) The PatternCount fields return a 1 or 0 depending on whether there is a match (not always an exact match) to the Keyword. The PatternCount fields are totaled for each record, and the Find script merely finds records where the Total is greater than zero.

                     

                           PatternCount has its limitations of course because part of a word can bring a “1” (“law” being part of “lawyer”), but can be useful if you are not looking for exact matches.