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

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

Recommended Posts

Posted

Good Morning List,

I need a script that when I click a button will find orders due for the next 5 days. I would base this search off of the "DATE DUE" date field that is on my table.

Ideally it would be intuitive enough to leave out saturdays and sundays. I had this functionality in FMP 6 but when I upgraded the script no longer works and I cannot figure out why. Can any of you helpful souls out there provide a solution for me? I would greatly appreciate any help.

Thanks

Steve

PS Also, is there a preference I can set on this forum that will notify me if anyone responds to a post? I thught there was, but am unable to find that now.

Posted

Does the next 5 days include today or does it start tommorow?

Today is Wednesday so The next 5 days could be Today (Wednesday), Thursday, Firday, Monday & Tuesday or they could be Thursday, Firday, Monday, Tuesday & Wednesday.

Scripts would be different.

Posted

Try this script:

If [ DayOfWeek ( Get ( CurrentDate ) ) = 1 ]

Enter Find Mode [ ]

Insert Calculated Result [ A::Due_Date; GetAsText ( Get ( CurrentDate ) + 1 ) & "..." & GetAsText ( Get ( CurrentDate ) + 5 ) ] [ Select ]

Perform Find [ ]

Else If [ DayOfWeek ( Get ( CurrentDate ) ) = 2 ]

Enter Find Mode [ ]

Insert Calculated Result [ A::Due_Date; GetAsText ( Get ( CurrentDate ) ) & "..." & GetAsText ( Get ( CurrentDate ) + 4 ) ] [ Select ]

Perform Find [ ]

Else

Enter Find Mode [ ]

Insert Calculated Result [ A::Due_Date; GetAsText ( Get ( CurrentDate ) ) & "..." & GetAsText ( Get ( CurrentDate ) + 6 ) ] [ Select ]

Perform Find [ ]

End If

Posted

Here's something quick:

Show All Records

Go to Record/Request/Page [First]

Loop

If [Due_Date - Get(CurrentDate) < 0 or Due_Date - Get(CurrentDate) > 5]

Omit Record

End If

Go to Record/Request/Page [Next;Exit after last]

End Loop

You'll be left with the records you want. Obviously this is crude and doesn't take into account Saturday or Sunday, but you can fix that.

Posted

Thanks for all of the help! Once again the utility of this forum has proven to be extremely valuable! I have managed to develop a soultion that works by combining my own efforts with the suggestions provided.

Thank you,

Steve

Posted

Insert Calculated Result [ A::Due_Date; GetAsText ( Get ( CurrentDate ) + 1 ) & "..." & GetAsText ( Get ( CurrentDate ) + 5 ) ] [ Select ]

In this script step what is [select] ??

The script finds the next five days just fine, but does not factor out the weekends. For example, I set a date due of the 18th on one of my records, but this script only found through the 17th (sunday)

My syntax is correct except for [select]. does this mean to check the box "select entire contents"

Thanks, I'm 95% there, just need to figure out the weekend thing now!

Steve

Posted

[select] means the "Select entire contents" is checked.

I assumed that there would be no weekend dates. In my sample database I have the validation set to not allow Sunday or Saturday dates. (DayOfWeek ( Due_Date ) != 1 and DayOfWeek ( Due_Date ) != 7)

The script is set to cover the next 5 working days including today. If today is a Sunday then use tomorrow through Friday. If today is Monday use today through Friday. Otherwise use today through 6 days from today. Since there are no weekend dates in the database this gives the desired result.

Posted

Your profile lists 6, but you seem to be using 7 answers. So I'm assuming you're using 7. If so, you can cut out the Insert and GetAsText portions, as they're unnecessary in 7. You can make a simple script of

Set Error Capture [On]

Enter Find Mode [ ]

Set Field [Due Date; Get(CurrentDate) & "..." & Get(CurrentDate) + 6 - 2 * (DayOfWeek(Get(CurrentDate)) = 2)]

Perform Find [ ]

This solution assumes the script will never be activated during a weekend.

This topic is 7348 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.