I was assigned the task of “automating” a workflow process.
The application that I created starts by allowing a user to fill in the information about the process then click a “Submit” button. The button attempts to save the document, causing the validation process to begin. As the document fields validate, signature and date fields get filled in. The last step of the validation checks to make sure that the user chose to “Submit” or just “Save”. The option to submit will then send an email using the trusty old @MailSend(…). The email notifies the next user in the process that it is their turn to click their button.
All the rest of the users have the option to “Approve” or “Reject” their step in the process. The logic is the same. If the user approves the process then after validation (and figuring out who the next user is) the email is sent. Rejecting sends the email to the previous user. Again, all of this is using @MailSend(…).
The whole process was working great until someone pointed out that the emails were coming from the user that is clicking the button and they would like it to come from something more official (like the server). Unfortunately, changing the “from” or “principal” is not an option when assigning the parameters in @MailSend. (ie. If I want to use [INCLUDEDOCLINK]).
After hours of exercising my Google skills, I proceeded to create an agent (using lotusscript) to send the email. Several more hours of trying to get it to work, I am stumped.
Currently, I want the button to validate all the fields and save the document. After everything validates, I want the email to be sent to the appropriate people. Finally, the document needs to close without prompting the user to save the document again.
I know I’m asking for a lot, but I could use some expert help.
The code I’m using for the button is:
@If (@Command([FileSave]);
@Do (
@Command([ToolsRunMacro]; "SendMail");
@Command([CloseWindow])
);
@StatusBar("Save Unsuccessful")
)
It appears to be calling the agent after the document is closed. The first several lines of the agent are:
Dim workspace As New NotesUIWorkspace
Dim uiDoc As New NotesUIDocument
Dim document As NotesDocument
Dim … Some more variables …
Set uiDoc = workspace.Currentdocument
Set document = uiDoc.Document
The error is occurring at the last line because uiDoc is not being set to the current document. Running the debugger shows that there is no current document assigned to workspace.
Any help with this would be greatly appreciated.