October 13, 200421 yr 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.
October 13, 200421 yr 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.
October 13, 200421 yr Author Thanks for clarifying for me. The script should include CURRENT day. Thanks, Steve
October 13, 200421 yr 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
October 13, 200421 yr 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.
October 13, 200421 yr 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
October 13, 200421 yr 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
October 13, 200421 yr [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.
October 14, 200421 yr 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