March 29, 20205 yr 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] Loop 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 Tom
March 30, 20205 yr Your script doesn’t perform a find. First find the correct records, then use Replace Field Contents, instead of looping thru the records
March 30, 20205 yr 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!
March 30, 20205 yr Author 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 March 30, 20205 yr by Thomas Sanguinetti
March 30, 20205 yr 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 "Alert" Failed to set Due Date! exit script End if
March 30, 20205 yr Author 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
March 31, 20205 yr 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.
Create an account or sign in to comment