Filemaker Pro 12 - Applescript - Object not found 1728 - applescript

Edit: More info - Filemaker Pro 12, Mac OSX Mavericks. Also: I have put the global variables on the layout to make sure that they are getting set properly, and I have checked the folder to make sure the file exists.
I have a filemaker script with native applescript that stopped working after some time. The script is triggered when clicking on a photo in a filemaker container and causes the photo to open in preview. The error is Object Not Found - Unknown Error 1728
tell application "Filemaker Pro"
activate
tell window "Deals_Platform"
go to layout "Equipment Detail"
set photoPath to (get data of cell "_global_photo_path" of layout "Equipment Detail" of current record)
set photoFolder to (get data of cell "_global_photo_folder" of layout "Equipment Detail" of current record)
end tell
end tell
tell application "Finder"
activate
open folder photoFolder of folder "PRODUCTS_PHOTOS" of folder "CONTACT" of folder "Files" of folder "Customer Database" of folder "Business Files" of folder "PhD Assets" of folder "J Files" of folder "Documents" of folder "J" of folder "Users" of startup disk
open document file photoPath of folder photoFolder of folder "PRODUCTS_PHOTOS" of folder "CONTACT" of folder "Files" of folder "Customer Database" of folder "Business Files" of folder "PhD Assets" of folder "J Files" of folder "Documents" of folder "J" of folder "Users" of startup disk
close folder photoFolder of folder "PRODUCTS_PHOTOS" of folder "CONTACT" of folder "Files" of folder "Customer Database" of folder "Business Files" of folder "PhD Assets" of folder "J Files" of folder "Documents" of folder "J" of folder "Users" of startup disk
end tell
Old Script (this does not work either)
tell application "FileMaker Pro"
activate
set photoPath to (get data of cell "_global_photo_path" of current record)
set photoFolder to (get data of cell "_global_photo_folder" of current record)
end tell
tell application "Finder"
activate
open document file photoPath of folder photoFolder of folder "PRODUCTS_PHOTOS" of folder "CONTACT" of folder "Files" of folder "Customer Database" of folder "Business Files" of folder "PhD Assets" of folder "J Files" of folder "Documents" of folder "J" of folder "Users" of startup disk
end tell

Sorry to resurrect an old thread, but mcgrailm, FileMaker definitely does not require fields to be on the current layout—nor any layout, actually—for a calculation to reference them. It would need to be on the layout in order for a Go to Field or Go to Object script step to work, but that’s just common sense: you can’t select something that isn’t there.

Related

Move every file of every folder to another folder

I am looking to write an AppleScript to move every file in every folder to another folder.
Currently, this is what I have:
tell application "Finder"
move (get every file of every folder of folder "Source_Folder" of desktop) to folder "Destination_Folder" of desktop
end tell
But this throws an error saying: error "Finder got an error: Can’t get document file \"ALGE71FL.cpg\" of folder \"Destination_Folder\" of folder \"Desktop\" of folder \"THIS_USER\" of folder \"Users\" of startup disk." number -1728 from document file "ALGE71FL.cpg" of folder "Destination_Folder" of folder "Desktop" of folder "THIS_USER" of folder "Users" of startup disk
Where ALGE71FL.cpg is the first file of interest.
Any solutions to this?
If you are looking to move only the files in the folders and not the folders themselves. This following AppleScript code is one way to achieve your goal.
activate
set searchFolder to choose folder with prompt "Choose The Folder To Search"
activate
set destinationFolder to choose folder with prompt "Choose The Folder To Move Files To"
tell application "Finder"
set theFiles to (files of entire contents of searchFolder) as alias list
move theFiles to destinationFolder
end tell

Open iCloud in current Finder window with AppleScript

I'm trying to open iCloud in the current Finder window/tab. The below AppleScript works with any other folder.
How can I open iCloud in the current Finder window with AppleScript?
tell application "Finder"
reopen
activate
set p to "~/Library/Mobile Documents/"
set target of Finder window 1 to POSIX file p
end tell
The script doesn't work because the Finder is not able to expand the tilde in POSIX paths.
This is an alternative with a relative path.
set userLibraryFolder to path to library folder from user domain
tell application "Finder"
reopen
activate
set iCloudDriveFolder to folder "iCloud Drive" of folder "Mobile Documents" of userLibraryFolder
set target of Finder window 1 to iCloudDriveFolder
end tell
This isn't a complete answer because this won't open the iCloud folder in the current tab, but it does open the iCloud folder rather than the "Mobile Documents" folder:
tell application "System Events" to open folder "~/Library/Mobile Documents"
I'm not familiar with any method that will give you the best of both worlds. It seems that you either must settle for the "Mobile Documents" folder opening in the tab you want; or a new tab being created to open the folder you want.
This is easy.
Create an alias of the iCloud folder and place that on the local hard drive then use Apple Script to open the alias and that opens the iCloud folder:
set itemPath to "Macintosh HD:Users:username:folder:alias_name"
tell application "Finder"
set theItem to item itemPath
if (class of theItem) is folder then activate
open theItem
end tell

AppleScript copy files from a to b with any user name

I'm trying to copy all files from a folder to another.
This works only if I specify the full path including the name of the drive and the username.
This works:
tell application "Finder"
set a to folder "Macintosh HD:Users:Michael:Desktop:Files:"
set b to folder "Macintosh HD:Users:Michael:Desktop:Copies"
duplicate every file of a to b
end tell
But I want to have this compatible with any HDD naming and username.
So I'm looking for a relative path, equivalent to ~:Desktop.
The relative path equivalent is
set desktopFolder to path to desktop
tell application "Finder"
set a to folder "Files:" of desktopFolder
set b to folder "Copies:" of desktopFolder
duplicate every file of a to b
end tell
But the Finder has a property desktop which points always to the desktop folder of the current user.
tell application "Finder"
set a to folder "Files:" of desktop
set b to folder "Copies:" of desktop
duplicate every file of a to b
end tell
And – even shorter – the desktop folder of the current user is the "root" folder of the Finder
tell application "Finder"
duplicate every file of folder "Files" to folder "Copies"
end tell
Edit:
The equivalent to
~/Library/Containers/com.apple.iWork.Numbers/Data/Library/Application Support/User Templates
is
((path to library folder from user domain as text) & "Containers:com.apple.iWork.Numbers:Data:Library:Application Support:User Templates:")

Can't make folder of application file into integer in applescript

I am trying to write a simple applescript to move the contents of a file into the package contents folder of an application. I tried using automator to do this, but I was unable to access the package contents of the application. I am very new to applescript but this is what I have written so far.
tell application "Finder"
set source_folder to (choose folder with prompt "Select the Step5 Folder:")
set target_folder to folder "MacintoshHD:Applications:BlueJ.app:Contents:Resources:Java:userlib"
copy every file in folder source_folder to folder target_folder
end tell
Right now I am getting the following error
error "Finder got an error: Can’t make folder \"userlib\" of folder \"Java\" of folder \"Resources\" of folder \"Contents\" of application file \"BlueJ.app\" of folder \"Applications\" of startup disk into type integer." number -1700 from folder "userlib" of folder "Java" of folder "Resources" of folder "Contents" of application file "BlueJ.app" of folder "Applications" of startup disk to integer
I have tried googling the error and I have not found anything that has been applicable to what I am writing.
Thanks
Try:
set source_folder to (choose folder with prompt "Select the Step5 Folder:")
set target_folder to "MacintoshHD:Applications:BlueJ.app:Contents:Resources:Java:userlib"
tell application "Finder" to duplicate files of source_folder to target_folder
You specified 'folder' twice... the error was for moving the file to: folder folder path

How to create a folder (with subfolders) with Applescript

Filemaker has the ability to ake use of AppleScript.
From within Filemaker I want to create a new folder (with the name of a FileMaker field) that holds 6 subfolders.
I am a complete noob where it comes to Applescript.
This is my script so far:
tell application "FileMaker Pro Advanced"
set folder_name to cell "FolderName" of current record
end tell
tell application "Finder"
activate
make new folder at folder "Desktop" of folder "dick" of folder "Users" of startup disk with properties {name:folder_name}
end tell
tell application "Finder"
activate
make new folder at folder {name:folder_name} of folder "Desktop" of folder "dick" of folder "Users" of startup disk with properties {name:"subfolder"}
end tell
My problem is: the creation of "Subfolder1"
What is my mistake there?
Help is much appreciated
When you crate a new folder you can define various properties, but when refering to the folder just use the name, for example:
make new folder at folder folder_name of folder "Desktop" of folder "dick" of folder "Users" of startup disk with properties {name:"subfolder"}
Note that the result returned from making a new folder is a reference to that folder, so you can also do something like:
tell application "Finder"
set newFolder to (make new folder at folder "Desktop" of folder "dick" of folder "Users" of startup disk with properties {name:folder_name})
make new folder at newFolder with properties {name:"subfolder"}
end tell
Here is another approach:
set myPath to POSIX path of ((path to desktop as text) & folder_name & ":subfolder")
do shell script "mkdir -p " & myPath

Resources