Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

perform find from Applescript

Featured Replies

I am trying to write an Applescript that will perform a find for data in a given field. The data is already established by the first part of the Applescript which works fine. What I want the second part of the script to do is to :

go to a given layout,

enter find mode

go to a given field

enter the data created by the first part of the script

perform find

The following Filemaker script script "check dups" does this up to step "go to a given field". What I can't figure out is how to enter the data contained in adresse_complete into the field "adresse au complet". The "set cell" command in find mode gives a "write access denied" message.

tell application "FileMaker Pro Advanced"

	activate

	do script "check dups"

	set cell "adresse au complet" to adresse_complete

end tell

Would someone know what I need to do here?

What would be the point in not doing this natively instead?

What however can be done is this:


tell application "FileMaker Pro Advanced"

	set aVar to cell "myField"

	show (every record whose cell "myField" = aVar)

end tell

--sd

  • Author

Thanks for that. The point is that the data that is being used for the search is extracted from incoming emails via Applescript. If I do it natively, I imagine the only way to do so is with copy and paste through the clipboard. As this is not supposed to be the best way to go, I thought it would be best to stay within Applescript.

Anyway for the moment I am still not getting the result I was after. Perhaps if I show the whole code it will be more self-explanatory.

Once again, the first part of the script works fine, I just can't get Filemaker to do the search correctly.

tell application "Mail"

	set the_message to item 1 of (get selection)

	set message_text to content of the_message as string

	

	set nom to paragraph 4 of message_text

	if (count nom) is less than 7 then

		set nom to ""

	else

		set nom to text 7 thru -1 of nom

	end if

	

	set prenom to paragraph 5 of message_text

	if (count prenom) is less than 10 then

		set prenom to ""

	else

		set prenom to text 10 thru -1 of prenom

	end if

	

	set adresse to paragraph 6 of message_text

	if (count adresse) is less than 11 then

		set adresse to ""

	else

		set adresse to text 11 thru -1 of adresse

	end if

	

	set nlp to paragraph 7 of message_text

	if (count nlp) is less than 7 then

		set nlp to ""

	else

		set nlp to text 7 thru -1 of nlp

	end if

	

	

	set ville to paragraph 8 of message_text

	if (count ville) is less than 12 then

		set ville to ""

	else

		set ville to text 12 thru -1 of ville

	end if

	

	

	set telephone to paragraph 9 of message_text

	if (count telephone) is less than 13 then

		set telephone to ""

	else

		set telephone to text 13 thru -1 of telephone

	end if

	

	set email to paragraph 10 of message_text

	if (count email) is less than 12 then

		set email to ""

	else

		set email to text 12 thru -1 of email

	end if

	

	

	set sexe to choose from list {"f unfamiliar", "f familiar", "m unfamiliar", "m familiar", "plural  unfamiliar"}

	if class of sexe is list then

		--OK clicked

	else

		--Cancel clicked

	end if

	

	set adresse_complete to sexe & prenom & " " & nom

	

	

end tell

tell application "FileMaker Pro Advanced"

	activate

	set adresse_complete to cell "adresse au complet"

	show (every record whose cell "adresse au complet" = adresse_complete)

	

end tell



All you're doing there at the end is setting an AppleScript variable to the value in a FileMaker field (cell), then doing a Find for that value. It would be from the 1st record in the found set, as you have not specified the current record. So that's going to Find that record (and possibly others).

In other words you are overwriting your AppleScript variable, adresse_complete, which you've just carefully set before you called FileMaker. That makes little sense.

Probably you do not want that line that resets the variable.

Edited by Guest

  • Author

In other words you are overwriting your AppleScript variable, adresse_complete, which you've just carefully set before you called FileMaker. That makes little sense.

Probably you do not want that line that resets the variable.

Yes, thank you, I understand that however just deleting «set adresse_complete to cell "adresse au complet"» isn't enough, I get an error saying that the Filemaker Pro event isn't handled. Can you tell me what I need to do to get Filemaker to accept the variable ?

It just means that no records matching the criteria were found (keep in mind that the way you have it, it's looking for an exact match). You should wrap the search in a try block and handle the error.

  • Author

Thanks. Great. I've figured it out.

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.