AppleScript Printing with Preset

Hi,

I am trying to print in Applescript with a Printer Preset but can’t seem to get Applescript to print with the Preset. Can anybody assist? I am setting the ShellScript but can’t seem to locate where I am going wrong.

Any assistance would be great

Many thanks.

tell application "myApp"
eval "
	project := selectedObjects lastObject.
	predicate := NSPredicate predicateWithFormat:'displayName = \"TheScreenShot\"'.
	attachments := project fileAttachments.
	filteredAttachment := (attachments filteredArrayUsingPredicate:predicate) lastObject.

filteredAttachment retrieveAttachmentWithDelegate:nil error:nil.

localLocation := filteredAttachment cachedURL.

localLocation.
"
set theFIle to result
end tell

set strCMD to "osascript -l JavaScript -e '(strPath = decodeURI(\"" & theFIle & "\").slice(7)).slice(strPath.indexOf(\"/\"))'"
set strPosixPath to (do shell script strCMD)


set strPrinterName to "HP Officejet Pro 276dw MFP"
delay 0.05

do shell script "defaults write com.apple.print.custompresets.forprinter.strPrinterName com.apple.print.lastPresetPrefType 'Black and White - Draft'"
delay 0.05

tell application strPrinterName
	print strPosixPath with properties {target printer:"strPrinterName"} without print dialog
end tell