Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Find orders due next 5 days

Featured Replies

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.

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.

  • Author

Thanks for clarifying for me. The script should include CURRENT day.

Thanks,

Steve

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

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.

  • Author

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

  • Author

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

[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.

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.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.