1 2 Previous Next 16 Replies Latest reply on Feb 1, 2016 6:50 PM by jmproulx

    Remembering the Searched Fields

    jmproulx

      Is there way in a script to get access to the contents of the Specify Find Requests dialog box in order to record the searched fields ?

       

      It would be useful to retrieve the criteria that were used to create a found set for each e-mail sent through the Send Mail script step.

        • 1. Re: Remembering the Searched Fields
          Vaughan

          The Modify Last Find step will pull up the last find criteria. You could then walk through the fields and work out which are not empty.

          • 2. Re: Remembering the Searched Fields
            jmproulx

            I understand this possibility, but I have near 50 fields in this table. Can this exploration for the non-empty fields be automated ?

            • 3. Re: Remembering the Searched Fields
              Vaughan

              Doesn't matter how many fields there are. Just put them all onto a layout and script the process. Same for 1 field or 100.

               

              It could be done with some design functions and a couple of loops, without even leaving the current layout. Something like:

               

              something like:

               

              Go to Layout [ layout with fields on it ]

              Go to Field [ first ]

              loop

              If [ not is empty( current field ) ]

              <stuff here >

              end if

              Go to Field [ next, exit after last ]

              end loop

               

              However you'll need to also check for multiple find requests, which would appear as multiple records in the found set.

              • 4. Re: Remembering the Searched Fields
                jmproulx

                So I would scan the layout in Find mode with Go to Next Field and record all fields that are not empty ?

                • 5. Re: Remembering the Searched Fields
                  Vaughan

                  Yes. The advantage of walking through he fields on the layout is that there is no hard-coding of field names or anything that will break.

                   

                  Just make sure that all the fields are in the layout's tab order.

                   

                  It might also be possible to do this using Design functions and a calculation (to avoid having to change to the layout with the fields on it) but I don't know whether the functions will pull find criteria out in find mode.

                  • 6. Re: Remembering the Searched Fields
                    jmproulx

                    I undertand. Very useful, thank you.

                    • 7. Re: Remembering the Searched Fields
                      Vaughan

                      Processes like this (walking through fields with a script, or a looped calculation) mean that solving the process is a matter of woking out the script. The number of fields that have to be processed only affects how long the script runs.

                      • 8. Re: Remembering the Searched Fields
                        jmproulx

                        My problem was not with the number of fields really. I didn't know how to make the script look for a searched field (or criteria). With the Modify Last Find and Go to Next Field script steps, I know now how to do it.

                         

                        I still have one question : what layout should the script step Go to Layout go to ? The original layout or a new one specifically created for the purpose ?

                        • 9. Re: Remembering the Searched Fields
                          jmproulx

                          It works perfectly.

                           

                          After Modify Last Find, the script scans the fields (in the tab order) of the same layout I used to perform the find and I found the search criteria (fields that are not empty).

                           

                          Thank you again for this hint. Very valuable for me.

                           

                          Merci beaucoup.

                          • 10. Re: Remembering the Searched Fields
                            jrenfrew

                            There does seem to be a flaw in this logic

                             

                            If you have a table with three fields and two records thusly:

                            Record 1: fieldA = 1, fieldB = 1, fieldC=1

                            Record 2: fieldA = 1, fieldB = 1, fieldC = <empty>

                             

                            If you do a search for fieldA = 1 AND fieldB = 1 then it will find both records

                            If you walk over record1 collecting the fields which have content you will records fieldA, fieldB, fieldC

                             

                            if you then build a search from that data, and find records you will only find Record1 but not Record2.

                            • 11. Re: Remembering the Searched Fields
                              Vaughan

                              If by "records" you mean find criteria, you are correct.

                               

                              The complete script needs to see whether there are multiple find criteria, and also whether the criteria are omit or include.

                               

                              Another loop should do it.

                              • 12. Re: Remembering the Searched Fields
                                jmproulx

                                The script performs  a Find.

                                Then I record the fields that were used to perform that Find.

                                     On the same context, a Modify Last Find script step is executed in Find mode (by default).

                                     The script then pulls out only the fields that have contents, namely fieldA and fieldB.

                                This is exactly what I want.

                                 

                                I don't walk over the record found, but over the layout, in Find mode.

                                • 13. Re: Remembering the Searched Fields
                                  Vaughan

                                  When in Find mode, multiple find requests can be made to create OR searches. In Find mode they appear as (and are equivalent to) multiple records.

                                   

                                  The script as-is will only process the first find request. To handle multiple requests change it to (pseudocode)

                                   

                                  Modify Last Find

                                  loop

                                  <walk through fields and remember criteria>

                                  got to record/request [ next ; exit after last ]

                                  end loop

                                  • 14. Re: Remembering the Searched Fields
                                    Vaughan

                                    jrenfrew wrote:

                                     

                                    There does seem to be a flaw in this logic

                                     

                                    If you have a table with three fields and two records thusly:

                                    Record 1: fieldA = 1, fieldB = 1, fieldC=1

                                    Record 2: fieldA = 1, fieldB = 1, fieldC = <empty>

                                     

                                    If you do a search for fieldA = 1 AND fieldB = 1 then it will find both records

                                    If you walk over record1 collecting the fields which have content you will records fieldA, fieldB, fieldC

                                     

                                    if you then build a search from that data, and find records you will only find Record1 but not Record2.

                                     

                                    You assume we're looking at the fields in browse mode. We're not, we're in find mode, so the content of the fields is actually the search criteria.

                                    1 2 Previous Next