Jump to content

A "simple" script?


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

Recommended Posts

This one is most likely a no brainer for fm pros...but I am a novice at best.

I have a repeating date field that I need to auto enter the current date each time an inspection is performed. I can get my script to check for empty, enter the date, and advance to the next field, if not empty - but that's as far as I can go.

I'm thinking I need a loop in here some where to dig down untill I reach the first empty field, but I can't quite figure out the loop function.

Here's what I've got so far:

Go to field ["Recheck Date"]

If["IsEmpty{Recheck Date}"]

Insert Current Date

Else

Go to next field

End If

Any Suggestions??

Link to comment
Share on other sites

Here is a technique that does exactly what you are asking. The only difference is it copies a values to the first repetition.

http://www.filemakerpros.com/Copynext.zip

However, I would recommend using another file and a portal to enter the dates. In other words, each inspection date would be a new related record. It will make the script a lot easier and allow you to create some reports on inspection dates.

Link to comment
Share on other sites

Go to field ["Recheck Date"]

Loop

Exit Loop If[isEmpty(Recheck Date)]

Go to next field

End Loop

Insert Current Date

You should probably put another Exit Loop in there to deal with what happens if you don't have any empty fields. Endless loop = bad.

I agree with JMO, you'd almost certainly be better off using a related table (related file in FileMaker 5) to store those dates.

Link to comment
Share on other sites

Thanks to both for your help.

This will mostly likely land me in the "you don't even know what you don't know" category, but please excuse my lack of knowledge - I've got books on order :

I've done a few portals, and worked with related records a bit, but I'm not quite getting this one. Each time we get called to a property for a complaint, we generate a new record to track the complaint. Sometimes we have to go back 3-5 times before all repairs are completed.

I need to track each recheck by date, and then total the rechecks at the end of the month. Are you saying that each recheck would be a new file in a seperate database? If so, how do I relate them to the orginal file in the first db? We have a unique inspection number for each file, and it would make sense to use that number as the relation, but for some reason I can't get my mind around how to actually accomplish this!

Thanks again.

Darren

Edited by Guest
Link to comment
Share on other sites

Create three files:

Properties

Complaints

Visits

Create an auto-enter serial number primary key field in Properties, Complaints and Visits (although, you likely won't use the serial number in Visits). You might call them kp_properties_id, kp_complaints_id and kp_visits_id. Also, create a foreign key in Complaints for the Property ID and a foreign key in Visits for the Complaints ID. Finally, relate Properties to Complaints and Complaints to Visits using the primary to foreign key fields. Make sure to allow creation of related records when you create the relationships.

When you are done, you can create a portal in Properties to display all of the Complaints and a portal in Complaints to display all the visits for that complaint. With the Go to Related Record script step, you drill down from a property to a complaint. You can also create scripts to automatically add a record to the portal but for now, try entering them manually through the porta. First, you want to understand the relationships before you start writing scripts.

Link to comment
Share on other sites

This topic is 5653 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
 Share

×
×
  • Create New...

Important Information

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