Hi ,
Your script is not working because you are using doc , which is provided implicitly on business documents . As you are writing explicit script which does not take any scripting context you cannot use doc etc.
Try to write a query and get details of the document you are trying to retrieve.
Thanks
Uday