Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

Script for finding records within a given date range.


This topic is 6082 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Sadly I've pretty much solved my problem minus my final step.

Within my quote table I have two fields... one being "Search_Day_Start" and "Search_Day_End". Those are both used within a layout I have designed to have different variables you can modify and then clicking on a specific button to generate a report for it.

A simple report that would be generated would taking the two dates selected by the user and then displaying all quotes generated within that time period.

Within that script I broke the dates down into a text format and then used a few other various things to extract the day/month/year.

I would then generate a line of text based upon what I pulled out of the two dates.

3/22/2008 and 3/25/2008 produces the line

{3...3}/{22...25}/{2008...2008}

I have confirmed that this part is working and the correct things are being created. But when I switch to my "report" layout, enter find mode and set the field which is "date_create" (A date type field) to what I generated.. I basically get the issue on the find when it says there is no valid criteria in the request... but if I modify my find and just paste in the text I generated it works fine.

I'm posting a screen of my script to hopefully clear any of my nonsense up!

I'm also not 100% bound to my own script. I'm sure I skinned the cat with a spoon here.

-Jimmy

scriptSS.jpg

Posted

If the Search_Day_Start and Search_Day_End fields are date fields, I am pretty sure (I am not at my Filemaker machine right now to test this) that you could simplify this substantially:

# Script to search for date range

Go To Layout["MySearchLayout"]

Enter Find Mode[]

Insert Calculated Result["TheDateField"; Search_Date_Start & "..." & Search_Date_End]

Perform Find[]

The key is to use the Insert Calculated Result script step instead of the Set Field step. You certainly don't have to insert ranges for each part of the date.

David

Posted (edited)

that seems to fix my problem. I'm glad its done in a much cleaner form.

"The key is to use the Insert Calculated Result script step instead of the Set Field step. You certainly don't have to insert ranges for each part of the date."

What is the main difference between these two steps to begin with? Obviously they do behave a bit different and I think it does answer one other question I might have had in the past on a similar issue. When you get into those script steps it appears they both have a prmop to insert a calculated result but I know they are different.

Edited by Guest
Posted

Older versions of FileMaker did require the Insert workaround. I'm not 100% sure when they changed it, it may be just with FileMaker 9 -- but old habits die hard.

E.g., does everyone know that you can now script Replace without going to a layout with the field on it?

Posted

Comment--

I see that it works as you mention. Since this was the main reason I knew to use Insert Calculated Result, can you tell me how or where it would now be useful?

Vern--

It used to be that one used the Insert Calculated Result step for entries that wouldn't pass the field's validation (as when one wished to script in a date range in a Find). Obviously, that changed...

David

Posted

how or where it would now be useful?

Besides maintaining backward compatibility with scripts written in previous versions, it would be useful for those occasions where you want to insert something at cursor position, while keeping the cursor in the field - such as inserting boiler-plate text.

This topic is 6082 days old. Please don't post here. Open a new topic instead.

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
×
×
  • Create New...

Important Information

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