Jump to content
Sign in to follow this  
davidnickerson

Preserving Find Requests in Scripts (FM12)

Recommended Posts

In an existing solution for a client, I have a scripted modal loop that allows users to select from multiple criteria (value list checkboxes) and then generate bar charts based on the results.  The script collects the find criteria as multiple find requests, performs the find, and then omits certain records based on an "omit" checkbox that may have been checked prior to the script being run.

The client is requesting that the found set from the bar charts also be displayed in list view with the omitted records now included.

I had thought using Extend Found Set would allow me to simply include records with the Omit checkbox, but because the previous script has run, the original find criteria are gone.  Using Extend here just performs a new find for all records with the Omit checkbox.  I can't seem to find a way to save the existing existing found set in a new script, at least not in FM12.

Thanks for your help.

Share this post


Link to post
Share on other sites

To simplify my question:

1) Is there any way to preserve a previous find request and use it in a script?

2) Is there any way to Extend a found set in a script, when the original find request is no longer present?

Share this post


Link to post
Share on other sites
comment    1,369

Caveat: I did not understand your original question and I am answering your questions as theoretical ones.

1 hour ago, davidnickerson said:

1) Is there any way to preserve a previous find request and use it in a script?

You can use the Modify Last Find script step to restore the requests (plural) used by the most recent find. Of course, if the preceding find is scripted, you can store the criteria in variables and retrieve them from there.

 

1 hour ago, davidnickerson said:

2) Is there any way to Extend a found set in a script, when the original find request is no longer present?

Extending a found set adds newly found records to the existing found set, regardless of how the found set was created. The original find request(s) play no role here. 

 

Share this post


Link to post
Share on other sites
8 hours ago, comment said:

Extending a found set adds newly found records to the existing found set, regardless of how the found set was created. The original find request(s) play no role here. 

I must have misunderstood Extend, although I've used it before.  I thought it was, in effect, the opposite of Constrain.  In the aforementioned modal script, I constrain a found set (the result of the user's find requests) to Omit records where the "omit" checkbox was checked.  Now, using this new found set I need another script that will simply add back in the omitted records.  Modify Last Find does not do this, nor (as you state) does Extend.  Is there not a script step or alternative method for including previously omitted records?  Thanks for your help, by the way.

8 hours ago, comment said:

 

 

Share this post


Link to post
Share on other sites
comment    1,369

I am afraid now you have lost me again. I don't understand your description at all (what on earth is a "modal script"?).

 

4 hours ago, davidnickerson said:

I must have misunderstood Extend, although I've used it before.  I thought it was, in effect, the opposite of Constrain.

Extend Found Set is the opposite of Constrain Found Set: the former adds records to the found set, the latter removes records from the found set.

More precisely, both operations combine the current found set with the results of the find operation: Constrain Found Set returns the intersection of the two sets, while Extend Found Set returns their union. 

 

4 hours ago, davidnickerson said:

I need another script that will simply add back in the omitted records.

Again speaking in general, you have the following options:

  • If you know by which criteria those records were omitted, you can use the same criteria to find them and add them to the current found set (using Extend Found Set as explained);
  • If you don't know, you can possibly find out by restoring all the requests of the last find (using Modify Last Find) and identifying the one of interest (perhaps it's the only one with the Omit box checked?);
  • If - as you say - the previous find is scripted, use that script to remember the criteria;
  • Open a new window before omitting the records and do whatever you need to do there; when you're done, close the window and return to the original found set as it was before the omit operation.

 

  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)
On 7/8/2017 at 1:46 AM, comment said:

I am afraid now you have lost me again. I don't understand your description at all (what on earth is a "modal script"?).

The script to which I refer includes a modal loop that pauses for user interaction (find requests).

On 7/8/2017 at 1:46 AM, comment said:

More precisely, both operations combine the current found set with the results of the find operation: Constrain Found Set returns the intersection of the two sets, while Extend Found Set returns their union. 

Indeed.  I was hoping for a scripted process to "reverse" the constrain.  I.E., the same find criteria that resulted in the found set, but including the records that were omitted before.  Not the found set combined with every record in the database that has omit checked.

On 7/8/2017 at 1:46 AM, comment said:
  • If you know by which criteria those records were omitted, you can use the same criteria to find them and add them to the current found set (using Extend Found Set as explained);
  • If you don't know, you can possibly find out by restoring all the requests of the last find (using Modify Last Find) and identifying the one of interest (perhaps it's the only one with the Omit box checked?);
  • If - as you say - the previous find is scripted, use that script to remember the criteria;
  • Open a new window before omitting the records and do whatever you need to do there; when you're done, close the window and return to the original found set as it was before the omit operation.

Thanks for the suggestions.  I can certainly achieve a solution by capturing all of the previous script's find requests using global variables and then rebuilding all of the requests via loops in a new script.  I was hoping to avoid that because it seemed inelegant.  Knowing that FileMaker has various ways to work with find requests (Saved Finds, Modify, Constrain, Extend) I had hoped there was a simple, elegant way to restore JUST the omitted records from the found set.

Edited by davidnickerson

Share this post


Link to post
Share on other sites
comment    1,369
3 hours ago, davidnickerson said:

The script to which I refer includes a modal loop that pauses for user interaction (find requests).

I have  no idea what you mean by "a modal loop" either. You can't invent your own vocabulary and expect others to understand what you're talking about. 

 

3 hours ago, davidnickerson said:

 I.E., the same find criteria that resulted in the found set, but including the records that were omitted before.  Not the found set combined with every record in the database that has omit checked.

This thread has been going on for some time and I still can't figure what's the problem you're trying to solve. Records do not have omit checked - find requests do. If you restore an omit request, uncheck the omit and use it to extend the found set, you should get back the found set as it was before the omit action (assuming no other changes were performed in the meanwhile).

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×

Important Information

By using this site, you agree to our Terms of Use.