This post will help you to understand how we can dynamically change the default printer from a FM DB using apple scripts.
Step 1:
Create four global fields in queries table.
Step 2:
Get the default printer in the system and assign it to a field Name “G_Default_Printer” using a “Perform AppleScript” command as
set cap to (do shell script “lpstat -d”)
tell application “FileMaker Pro Advanced”
set cell “G_Default_Printer” of table “Admin” to cap
end tell
Step 3:
Get the list of printers IP address in the system and assign it to a field Name “G_Printer_IP” using a “Perform AppleScript” command as
set cap to (do shell script “lpstat -v”)
tell application “FileMaker Pro Advanced”
set cell “G_Printer_IP” of table “Admin” to cap
end tell
Step 4:
Get the list of printers in the system and assign it to a field Name “G_Printer_Name” using a “Perform AppleScript” command as
set cap to (do shell script “lpstat -p | awk ‘{print $2}’ ” )
tell application “FileMaker Pro Advanced”
set cell “G_Printer_Name” of table “Admin” to cap
end tell
Step 5:
Extract the default printer name from the “G_Default_Printer” and assign it to variable “Def_Printer” using script line as
“Trim ( Right ( Admin::G_Default_Printer;Length ( Admin::G_Default_Printer )- Position ( Admin::G_Default_Printer;”:”;1;1 ) ) )“
Step 6:
Assign printer IP address to a variable as “Printer IP”

Step 7:
Extract that specific printer name from its IP address using the list of printers IP address which is mapped with the variable “Printer IP”.
Step 8:
Assign the extracted printer to the default printer of the system using “Perform AppleScript“
“do shell script \”lpoptions -d ” & $Printer &”\””
Step 9:
Now Print the document.
Step 10:
Reset back the default printer from the Variable “Def_Printer” using “Perform AppleScript“
“do shell script \”lpoptions -d ” & $Def_Print &”\””
Hope you understand the solution above. If you are still need any help to implement this into your own solutions. Please, contact us. FMDBSolutions is a team of well-qualified experts that have a lot of experience with the many versions of FileMaker Pro and the FileMaker Go app too.
Our team knows all about transitioning, migrating, converting, and upgrading for FileMaker. Companies that require FileMaker Integration can also use our services. We have worked with clients from the USA, Australia, and Singapore and will complete your FileMaker assignment in the best possible way at a lower price but the same or higher level of excellence.
If you want solutions to your FileMaker database, we can help. Click the below box for a free FileMaker consultation
You can also leave us your email below for receiving new updates regarding FileMaker and our company.



furtdsolinopv
I’ve been surfing on-line greater than 3 hours today, but I by no means discovered any fascinating article like yours. It?¦s pretty value sufficient for me. In my view, if all site owners and bloggers made just right content material as you did, the web shall be much more useful than ever before.