Script problem sending documents

Ed wrote:

We’re trying to send a document to a user through a script.

The BODocument method “Send” [page 110 of the 1997 Developer’s Handbook;
page 117 of the 1998 version] only seems to works if we leave off the name
of the user (even though the the command syntax allows for a user name).
Once we add a user name or a group name, the script still compiles (though
not if I pass the second and third arguments shown in the syntax), but
fails
at runtime with an error R2012 “Error during execution”.


Listserv Archives (BOB member since 2002-06-25)

On Tue, 9 Feb 1999 11:04:11 -0800, Ed Stickgold eds@MEDIMPACT.COM wrote:

The BODocument method “Send” [page 110 of the 1997 Developer’s Handbook;
page 117 of the 1998 version] only seems to works if we leave off the name
of the user (even though the the command syntax allows for a user name).
Once we add a user name or a group name, the script still compiles (though
not if I pass the second and third arguments shown in the syntax), but fails
at runtime with an error R2012 “Error during execution”.

We need to send this document to specific users or groups in order to avoid
the popup dialog box that appears if no name is given.

Hi Ed,

Here are two scripts. The first one is for sending to users and the
second one is for sending to groups in the repository. They are probably
similar to what you are using.

Sub Main
Application.ExchangeRepository = “DevDocument”
Application.ExchangeMode = UserMode
ActiveDocument.Send(“userNameA”)
End Sub

Sub Main
Application.ExchangeRepository = “DevDocument”
Application.ExchangeMode = RepositoryMode
ActiveDocument.Send(“groupName1”)
End Sub

I’ve seen the runtime error, “R2012 Error during execution,” occur whenever
something is wrong with the Send. Here are some examples:

  1. when the repository name is incorrect
  2. when the user or group does not exist
  3. when the ExchangeMode is “RepositoryMode” and you are trying to send
    to a user, and vice versa
  4. if you are trying to use the script to send a document to your
    own user id; this will not work, just like you can’t use
    File | Send To Users… to send a document to yourself because
    your user id is not available in the list box

have repository mode on instead of user mode


Listserv Archives (BOB member since 2002-06-25)

Once we add a user name or a group name, the script still compiles (though
not if I pass the second and third arguments shown in the syntax), but fails
at runtime with an error R2012 “Error during execution”.

One more thing. (I hit the send button too quickly.)

You may be able to get the script to compile when you include the second
and third arguments by prefixing the statement with the Call command.
I’m not exactly sure why this works, but it may have something to do with
the Send method being defined as a subprogram.

Chad Berghorst
Gordon Food Service


Listserv Archives (BOB member since 2002-06-25)

In a message dated 99-02-11 08:55:42 EST, you write:

<< stuff deleted >>

Sub Main
Application.ExchangeRepository = “DevDocument”
Application.ExchangeMode = RepositoryMode
ActiveDocument.Send(“groupName1”)
End Sub

I’ve seen the runtime error, “R2012 Error during execution,” occur whenever
something is wrong with the Send.

I am in the process of working on a script to manage document agent
submissions. I, too, have encountered the run time error (error during
execution) when something is wrong (ie the document name used in the
“retrieve” does not exist).

Here’s the problem: I am retrieving documents from the repository based on a
flat file of directions (processing instructions). I need a way to trap the
error when a file or group name does not exist in the repository, so the
script can continue. Having the script simply fail with a run time error is
not a viable alternative…

Can any of the scripting gurus on the list help me out here?

The syntax for a retrieval is:

     Application.Documents.Receive(myDocName)

where myDocName is filled with a supposedly valid document name. If the name
is invalid, the script currently stops. I need a way to trap the failure, log
an error, and continue. Of course if the name is correct, everything works
fine.

Regards,
Dave Rathbun
Integra Solutions
www.islink.com


Listserv Archives (BOB member since 2002-06-25)

In a message dated 99-02-18 16:49:49 EST, you write:

The syntax for a retrieval is:

      Application.Documents.Receive(myDocName)

where myDocName is filled with a supposedly valid document name. If the
name
is invalid, the script currently stops. I need a way to trap the failure,
log
an error, and continue. Of course if the name is correct, everything works
fine.

Solved my own problem, just had to stop and think about it for a while. The
following code (which was obvious, in retrospect) will do the trick of
retrieving a document, and trapping the error if the document is not
available.

Function RepoFileExist (myFileName$)

’ First Check to ensure that myFileName is a valid file in the repository

On Error Goto NotFound ’ provide alternate error handling

’ attempt to retrieve file
Application.Documents.Receive(myFileName$)
On Error Resume Next ’ if success, restore default error
handling

RepoFileExist = True

Exit Function

NotFound:
On Error Resume Next
RepoFileExist = False
LogError (“File " & myFileName$ & " not available in repository.”)

End Function ’ Repository File Exists

Calling the function looks something like this:

If RepoFileExists (document_name) Then
… do file process stuff here…
Else
… log to error file here
end if

Since the function retrieves the file if it exists, the processing loop can
start with the assumption that the file is present. It does, however, seem to
want to only retrieve the file to the standard BusObj document directory.

So, thanks for any consideration you may have given to my question, but I seem
to have solved it!

Regards,
Dave Rathbun
Integra Solutions
www.islink.com


Listserv Archives (BOB member since 2002-06-25)