paulage77 Posted May 9, 2003 Posted May 9, 2003 I have a portal that contains 3 fields. two standard text fields and one field that is a check box for "yes/no". This too is a text field, it's just based on a value list [Yes:No]. The portal itself is based on a self join relationship of a calculated field. No biggie all is displayed well. The goal is to be able to loop through the portal and find the first record with the radio button checked Yes, then grab the text from one of the above mentioned text boxes of the same record and copy it onto the current or master record (the one containing the portal). I'm not sure how to do this, although my gut feeling is that I will need to do some sort of loop on the related records and not really use the "go to portal row" script step. What I'm having trouble with is, looping through all the related records find the the first "yes" one and then copy the data back to the original record text field. I hope this isn't too confusing, I think it's probably not too hard, I just get confused on the navigation.
Lee Smith Posted May 9, 2003 Posted May 9, 2003 The information doesn't exist in the portal, it exist in the child file. You will to do your search in that file.
paulage77 Posted May 9, 2003 Author Posted May 9, 2003 By child file I guess you mean, the referred to record? That is, the record from which the portal data comes from. Not sure of the correct terminolgy, but I think I know what you are saying. I think having the existance of the "go to portal row" got me thinking there may be an easier way, as I am having difficulties organizing the script.
Lee Smith Posted May 9, 2003 Posted May 9, 2003 Hi Paul, Sorry, I usually only use FileMakers terms for relationships, but didn't in this case. You are correct. The related record is the same as Child. In any event, the portal is only a way to see this information in the related file, but it really only exists in the related file, HTH Lee
Peter Fenner Posted May 9, 2003 Posted May 9, 2003 Hi Paul If you only need the first result in your portal with a "yes" result then the simple solution would be as follows: Create another relationship exactly the same as the one used for your portal - but sort it by the yesno field (descending). Well call this relationship R2 Now, lets call your existing text fields as text1 and text2 and the fields you want to copy to on the layout with the portal we will call master1 and master2. Now your script must: SetField [master1,R2::text1] and SetField [master2,R2::text2] That is all you need to do, because of your sort order in the relationship the record with the first yes will be referred to. Pete
Ugo DI LUCA Posted May 10, 2003 Posted May 10, 2003 Hi Pete, I finally see some good stars here under your name Yes, this is actually a good one. In addition to what Pete just said, using the sorted relationship, you may have 2 other options. 1.lookup fields from the related file 2. simple related fields Now if one day you want a list of all first records being tag with a Yes in the related file, use this method. In the related file, create : 1. a global field g_yes (obviously text with "yes") 2. a concanateglobal = g_yes & " " & Foreign Key 3. a concanateindex = yes/no & " " & Foreign Key 4. A selfjoin concanateglobal::concanateindex 5. a calculation = Case(Record_ID = Selfjoin::Record_ID,1,0) This will tag any first yes record related to the Main file (using the Foreign Id). As this is an unsorted calculation, you cannot use it directly with a Go To Related Record, but you can make a find on it or again sort your relationship based on this calculation.
paulage77 Posted May 12, 2003 Author Posted May 12, 2003 Excellent idea! I'm going to try this out, and I will let you know how it goes. Thanks a lot!!
paulage77 Posted May 12, 2003 Author Posted May 12, 2003 Wow, that worked like a charm, thanks a bunch Peter. I didn't even know about the sorting option for relationships. Ugo, I deffinetly forsee an upgrade like you have mentioned. This Forum rocks!
Recommended Posts
This topic is 7869 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 accountSign in
Already have an account? Sign in here.
Sign In Now