danek Posted May 26, 2008 Posted May 26, 2008 Hi all, Is it possible to do a loop within a calculation (in Define Fields) OR to call a user-defined script from within a calculation? Each record has a set of related records. I want to define a calculation field displaying a particular related record if and only if it meets other criteria as well. Right now I have a calculation which looks really ugly (I am inexperienced with FileMaker scripting please don't yell at me!): If (GetNthRecord(Foo::Bar;1) = "Criterion"; GetNthRecord(Foo::Foo;1); "") & If (GetNthRecord(Foo::Bar;2) = "Criterion"; GetNthRecord(Foo::Foo;2); "") ... etc I couldn't figure out a way to lookup a related record from the list of related records based on the value of one of its fields (not the field that creates the relationship, and i don't want to make another occurrence of the table in the relationship graph) so this was the next best thing I was able to get going. There is probably a better way. I'd be happy if I could just do the above, but with a loop. If not a loop in the calculation itself, perhaps by calling a script.
comment Posted May 26, 2008 Posted May 26, 2008 Recursive calculations are possible within custom functions - but you need the Advanced version for writing/installing custom functions. Another option is to use a repeating calculation field - see: http://fmforums.com/forum/showtopic.php?tid/137788/
Tori Mitchell Posted May 26, 2008 Posted May 26, 2008 In an aside to comment, I'll chime in that this kind of logic would be better implemented with a CustomFunction... keeps things more sane when you (inevitably) have to come back to it.
danek Posted May 26, 2008 Author Posted May 26, 2008 If a database is created with Advanced, can it be used (custom functions and all) on the regular version of FileMaker Pro? I think I will just do all my "loop" iterations by hand for now; it's not a big deal in this case. Thanks. (I tried to get it to work by doing a Calculation Repetition, but this ended up making my field a repeating field, which wasn't exactly a desired effect.) Thanks guys.
comment Posted May 26, 2008 Posted May 26, 2008 (edited) If a database is created with Advanced, can it be used (custom functions and all) on the regular version of FileMaker Pro? Yes. I tried to get it to work by doing a Calculation Repetition, but this ended up making my field a repeating field, which wasn't exactly a desired effect. You could use List ( RepeatingField) in a second, non-repeating calculation field. EDIT: Well, you could - if you had version 8.5 or higher. Edited May 26, 2008 by Guest
Recommended Posts
This topic is 6085 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