OK, I understand a little better now.
The trouble is that Filemaker will only return a string object as the result of the get cell line. Although, to us, the string returned from Filemaker matches the options for ‘type’ as far as AuthPay is concerned, AppleScript sees them as totally different.
The easiest way to deal with this is to simply:
tell application "FileMaker Pro"
set saletype to cell "saletype" in current record in document "DISH USA INVOICES"
set accountnumber to cell "Account" in current record in document "DISH USA INVOICES"
end tell
then:
tell application "AuthPayX Client"
make new sale
if saletype = "Normal" then
set the type of sale 1 to Normal
else if saletype = "Preauthorize" then
set the type of sale 1 to Preauthorize
else if saletype = "Refund" then
set the type of sale 1 to Refund
else if saletype = "Force" then
set the type of sale 1 to Force
end if
In this way you’re kind of translating between strings and values understood by the application.
There’s one other thing I would change, too, which is the way you’re referencing the sale in AuthPayX.
In your code you are setting “type of sale 1 to x” which is OK but dangerous. While it might work all of the time in testing, it is ambiguous and may fail in the real world.
For example, what would happen if two sales came in very close to each other?
The first sale is for a $100 preauth and while this is processing another sale comes in as a normal $20 sale.
Since you’re using ‘sale 1’ the commands that are directed to the latter sale (normal $20) would be applied to the first one ($100 preauth), which is not what you want.
Instead, you should use a reference to the specific sale you’re processing:
tell application "AuthPayX Client"
set thisSale to make new sale
At this point, thisSale is a reference to a specific sale object as far as AuthPay X is concerned. If you looked at it from AppleScript’s perspective, it’s probably something like "sale ID 12345 of application “AuthPayX Client” - absolutely unambiguous and when it comes to setting the sale type:
set type of thisSale to Normal
this (internally) translates to ‘set type of sale ID 12345 of application “AuthPayX Client” to Normal’ which, again, is unambiguous and unaffected by any other actions going on at the time. Each run of the script would have ‘thisSale’ referencing a different sale object within AuthPayX Client and you’ll never run into an overlap.
This may not be a big deal for you right now, but it may be if you start processing lots of sales, and may definitely be in other applications, so it’s a good habit to get into.