@nikivi, @gglick has given you the answer.
If you are going to work with AppleScripts in KM, then you might save yourself a lot of time and trouble if you read some of the KM Wiki:
Did you know you can quickly get help from the KM Wiki directly from every KM Action? Just click on the Gear menu, and select "Help".
EDIT: Just posted this pair of macros for you and everyone!
Macro Set to Quickly Get KM Help
As you know, we are always glad to help around here, but you might be able to get the answer faster from the KM Wiki, or by search this forum.
Good luck scripting!