Jump to content

Simple Script to change dates on a task list

Recommended Posts

  • Newbies

Hi there,

I am writing this post in order to request some assistance in creating a simple script which will allow me to find a number of records matching a certain criteria and then modify the date of those tasks.

Brief - 

I have a simple database of which the primary function is to keep a record of jobs. A task list essentially. Each record has a number of fields included due date and status. Status are a pre defined list of string possibilities such as ''Open", "Complete", "In Progress".

I have written a script which will find all records that have a due date of (today) and status of 'In Progress'. The script will then alter the due date of these records by one day. The script i have written however successfully moves the records forward by one day but doesn't consider the status. It moves all records regardless. Please see my script below and i would love some assistance on what tweak is needed in order to accomplish this. Problem comparing the contents of the status field with the string 'In Progress' ?'

Script - 

Set Variable [ $TODAYSTASKS ; Value: Tasks::Due Date = Get(Current Date) and GetField ("Status") = "In Progress"]

Go to Record/Request/Page [First]


Set Field [Tasks:: Due Date ; Get ( Current Date ) + 1]

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

End Loop

Thank you very much for anyones help in advance




Link to post
Share on other sites

Like Steve said, your script has no Find. Are you wanting to do something like:

If[ Tasks::Status = "In Progress" ]
  Set Field... etc.
End If

Notice that you don't need GetField.

Welcome to the forums!

Link to post
Share on other sites
  • Newbies
21 hours ago, Steve Martino said:

Your script doesn’t perform a find.

First find the correct records, then use Replace Field Contents, instead of looping thru the records

I would like to find all the records with a due date of todays date and a status of 'In Progress' and then set the due date field to current date + 1 on all of those records.

Rewriting the script now.

Thanks for both of your advice !! Let's see what happens

Edited by Thomas Sanguinetti
Link to post
Share on other sites

Remember, if you are editing more than one record and it is essential that all are edited, then you need a transaction. Unfortunately, there's no "built-in" Start Transaction in FileMaker, and since you're a newbie, I'll just refer you to a video.  

Replace All will not tell you if one of the tasks failed to have its Due Date modified correctly.

Set Field will, at least, provide an error if the set fails (someone else has the record locked).

So, consider this pseudocode:

Set Field DueDate = DueDate + 1

set Var $error  = Get ( LastError)

If $error

Show Custom Dialog


Failed to set Due Date!

exit script

End if


Link to post
Share on other sites
  • Newbies

Thanks for your assistance. It helped me establish which FM script functions i needed to perform the tasks. The logic of the situation is pretty straight forward

The task was completed with script attached below where the find function selects records with the specified due date and status.

As the kind person above mentioned this does not include error control which i will put in at a later date.

Thanks all

Screen Shot 2020-03-30 at 6.34.25 PM.png

Link to post
Share on other sites

I recommend not using perform find with restore because you cannot see the criteria easily. Instead adopt the pattern:

enter find mode (no pause)

set field  ; mycriteria 

perform find

Error capture 

if no error

Do stuff. 

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

Important Information

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