bdarch Posted March 28, 2008 Posted March 28, 2008 Hello all, I need to copy/paste single contact record info out of filemaker and into the mac clipboard. To do this I've created a calc field to concatenate the various fields into an organized text string with line breaks. I have a little script to put the contents of said calc field into the clipboard. So far so good. Here's the thing I can't figure out: related fields - specifically tel numbers and the tel number tags stored remotely and called in by a contact ID number relating the files to each other. How can I get all the related records (list of telephone numbers with tags) into my calc field for pasting? Thanks so much for your help.
Fitch Posted March 29, 2008 Posted March 29, 2008 You don't necessarily need a calc field, you can calculate the AppleScript like so: "set the clipboard to " & Quote( contacts::name & " " & contacts::etc ) To get the related info, if it was just one field, you could use the List function. With two fields, you could create a calc field in the related file that concatenates the two and then use List on that. Or, you could script it using a Loop: Set Variable( $count ; Count(related::phone) ) Set Variable( $i ; 0 ) Loop Set Variable( $i ; $i + 1 ) Exit Loop If ( $i > $count ) Set Variable ( $text ; $text & ¶ &GetNthRecord( related::phone ; $i ) & GetNthRecord( related::tag ; $i) ) End Loop
bdarch Posted March 30, 2008 Author Posted March 30, 2008 Fitch Thanks - I'll take a look at the List function. By "AppleScript" do you mean just that - AppleScript outside of FileMaker? It's been a while since I messed around with that! :)
Fenton Posted March 30, 2008 Posted March 30, 2008 No, he means AppleScript inside FileMaker, using the Perform AppleScript step, which can accept either a FileMaker calculation field or the text of the AppleScript (which is then compiled upon closing the window). If you use a calculation field, then you must escape any quote marks that you want to pass to AppleScript, include returns where necessary, etc.. In other words, AppleScript transcends the boundaries of applications (kind of mystical -), especially in FileMaker's case, which can contain the AppleScript code within one of its objects (I don't know of any other app that can do this, though some are "recordable," which is a whole 'nother thing). Basically you'd be using it to set the clipboard directly, rather than using a Copy step; which you also could do.
Fenton Posted March 30, 2008 Posted March 30, 2008 Another place you might want to look is at Brian Dunning's Custom Functions list. http://www.briandunning.com/filemaker-custom-functions/list.php There is one called "GetRows" (also requires "GetNthRow") which can produce a text result of what is in a portal, multiple fields, multiple lines, without having to create a concatenated calculation field. You can even use a tab separator, if you copy/paste one in.
bdarch Posted March 31, 2008 Author Posted March 31, 2008 Ah - of course. I remember dabbling with embedded Applescript years ago. The add-on function looks promising - thanks for that link. :)
bdarch Posted March 31, 2008 Author Posted March 31, 2008 OK my friends - thank you so much for your help. The custom function is workin' like a charm. Except... I'm stuck on the following: Is there a way to define N in the above function dynamically? The portals the function is reading from don't have a predicable number of records shown. I'd like to copy all of them each time the function is invoked.
Recommended Posts
This topic is 6141 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