2 Replies Latest reply: Feb 10, 2011 12:52 PM by Tom Nash
Funky247 Level 1 Level 1 (0 points)
Hello,

I've been asked to look into ways and means of getting MYOB to generate invoices for certain services on a annual basis (subscription based services).

Since the program can export reminders to iCal I opted to use this functionality, set them to repeat and attached a script to the alarm. The intention being that when the alarm is set off the script would open AccountEdge and generate an invoice, print it off and then fire of an email to the accountant.

Unfortunately AccountEdges support for applescript is, well unsupported by Mamut (who are worse than useless btw) and I'm having issues with working out which bit is throwing up the error message. This is the code thats breaking:

Code:
import one sale of type item from "items.dat" username user_name password user_pass separated by tabs first record is header with add card


The bit that seems to be causing the issue is "items.dat" which is the file I should be importing the sale from, I'm uncertain as to what syntax I should be using, or even which file the programs should be pointed at.

Has anyone got any experience with this kind of thing at all. Failing that, is there another way to generate an invoice on an annual basis, I'm trying to introduce some streamlining so the more hands off the better.

Hopefully this made some sense, let me know if you require any further info. Below is the full script I'm using along with the error message its throwing up.

Code:
(*This script exports stuff from MYOB.*)

(*Set your paths, user and password here.*)
set user_name to "Administrator" as string
set user_pass to "" as string
set path_import to "Macintosh HD:users:chrisbannister:Scripts:MYOB:Data:Export:items.dat" as string
set path_myob to "Macintosh HD:users:chrisbannister:Documents:Accounts:Teh Partnersheep.myo" as string
set myob to application path_myob

(*Start MYOB if required.*)
tell application "Finder" to set tProcesses to name of processes

if (tProcesses contains "AccountEdge") then
set myobwasrunning to true as boolean
else
set myobwasrunning to false as boolean
activate path_myob
tell application "AccountEdge"
open path_myob as alias username user_name password user_pass
end tell
delay 2
end if

delay 2

(* Tell MYOB what to do *)
tell application "AccountEdge"
import one sale of type item from "items.dat" username user_name password user_pass separated by tabs first record is header with add card
end tell

(*Close MYOB if you opened it.*)
if (myobwasrunning is false) then
tell application "AccountEdge"
quit
end tell
end if


Code:
error "AccountEdge got an error: Can’t make some data into the expected type." number -1700 to item

I hope someone can help. Thanks in advance.

iMac, Mac OS X (10.6.6)
  • 1. Re: For the love of god, just make it stop! - Applescript error issues
    Camelot Level 8 Level 8 (45,790 points)
    I don't have MYOB, but the most obvious problem is:

    import one sale of type item from "items.dat" username user_name password user_pass separated by tabs first record is header with add card


    and just where is 'items.dat'? How is the app supposed to know? Should it scan the entire disk for a filename that matches? How does it know it's the right file?

    At the very least I'd expect this to be a file path, rather than just a file name:

    import one sale of type item from "HD:path:to:some:items.dat" username user_name password user_pass separated by tabs first record is header with add card


    even more likely is that it will need to be identified as a file specifier:

    import one sale of type item from file "HD:path:to:some:items.dat" username user_name password user_pass separated by tabs first record is header with add card
  • 2. Re: For the love of god, just make it stop! - Applescript error issues
    Tom Nash Level 1 Level 1 (15 points)
    Not sure if this is helpful but this script below works for me. I haven't tried the UK version though.

    set app_location to choose folder with prompt "Choose the folder where AccountEdge exists"
    set datafilename to choose file with prompt "Select your datafile"
    set importfilelocation to choose file with prompt "Choose the file you would like to Import"
    set app_fullpath to app_location & "AccountEdge.app" as string
    set app_name to application app_fullpath

    set user_name to "ADMINISTRATOR"
    set password_master to ""

    activate app_name

    tell application "AccountEdge"

    open datafilename as alias username "ADMINISTRATOR" password ""
    delay 3

    import one sale of type service from importfilelocation username user_name password password_master with add card

    end tell