Jump to content
Server Maintenance This Week. ×

Adding Script for Many-to-Many


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

Recommended Posts

  • Newbies

Hi Everyone,

I'm working on a many-to-many relational database and I'm having trouble writing a script. There are 3 databases: Teachers, Events, and EventTeach (join file). I can add events to teachers and vice versa fine, but I want the Add Event script to check to see if that teacher already has a specific event associated with them so that duplicates events don't get added to one teacher. I don't know how to go about doing this. I was thinking about how to script current field info and then checking if it already exists as a record. Any help would be great. Thanks.

FileMaker Version: 5

Platform: Mac OS 9

Many to Many.zip

Link to comment
Share on other sites

Hey Ice,

Maybe you can loop through the related EventTeach records to see if the event to be added is already in there. I can give more detail, but is this what you have in mind?

Link to comment
Share on other sites

First, I tweaked your 'View' scripts to be less involved. A find isn't necessary if you have a relationship defined. So check your view scripts for how they've changed.

Second, you had a Pause/Resume based on EventID. This doesn't make any sense to me, so I'm assuming it should just be a normal P/R with an indefinite time.

Third, how is EventID to be defined? Is it manually entered or do you want the file to create the next available one?

IceLantern.zip

Link to comment
Share on other sites

  • Newbies

Ender,

Yes, that is exactly what I'm looking to do.

I want to be able to search through all of the records to make sure that a duplicate entry of a teacher and event combination is not already there and then prevent the user from choosing that event.

FileMaker Version: 5

Platform: Mac OS 9

Link to comment
Share on other sites

I would add events through the Teacher file. Have users select an event to add in a new field gEventID (Global). You might use a custom value list to show possible Event IDs. On the same layout, show a portal to the EventTeach file, but have record creation turned off on this portal. On a second "process" layout, have a portal with another relation to EventTeach with Allow creation of related records turned on.

Users select an Event to add for the teacher and hit an Add Event button. The button does the following script:

Go to Portal Row [ First ]

Loop

If [ gEventID = EventTeachView::EventID ]

Exit Record

Show Message [ "Event is already selected." ]

Exit Script

End If

Go to Portal Row [ Exit after last, Next ]

End Loop

Go to Layout [ Process - Event Add ] //an empty layout with a portal to EventTeach with Allow creation turned on.

Go to Portal Row [ Last ] //goes to the empty portal row so it can add a new one

Set Field [ EventTeachAdd , gEventID ] //inserts the new ID

Go to Layout [ original layout ]

FileMaker Version: Dev 6

Platform: Mac OS X Panther

Link to comment
Share on other sites

This topic is 7311 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
×
×
  • Create New...

Important Information

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