|
|
|
|
|
|
|
|
|
|
|
|
|
|
LotusScript agents and the Web (continued)
I pasted the graphic onto my form, selected it, and created an Action HotSpot around it with the following code:
UNID:=@Text(@DocumentUniqueID);
apprvr := @ReplaceSubstring(@Name([CN]; @UserName); " "; "+");
@URLOpen("/"+@ReplaceSubstring(@Subset(@DbName; -1);"\\";"/")+"/ApproveDoc?OpenAgent&UNID="+UNID + "&UserN="+ apprvr)
|
The first temporary variables are the parameters that we're going to pass to our LotusScript. First, we need to pass the unique ID of the document, which I'm setting to the UNID temp variable. Next, we need the name of the Approver, but we'll need to replace any spaces with plus (+) signs, since some browsers will interpret the space as a special character. We can then pass the two parameters by appending an ampersand (&) and a key name to the URL. The key name is important because our LotusScript agent will look for each key to find the parameters.
We'll set up the URL as with the following code:
…Approve?OpenAgent&UNID="+UNID + "&UserN="+ apprvr
|
UNID is the Document's Unique ID and UserN is the Approver's Name.
Backend processing Now that we have the button set up, it's time to code the agent that we're calling ApproveDoc. When we create this agent, it'll need to be set up as Shared, Run Manually from the Actions Menu Agent, with Run once (@Commands may be used) as the document to act on.
Now we're running LotusScript. The following is the entire code for the Agent. I'll discuss each main area below.
Sub Initialize
Dim docID, UserN As String
Dim lastname, firstname As String
Set Websession = New NotesSession
Set Webdoc = Websession.DocumentContext
QueryString = Webdoc.Query_String(0)
REM Get Unique ID of Document...
startP=Instr(QueryString, "UNID=")+5
endP=Instr(startP,QueryString,"&")
lenP = endP-startP
docID=Mid(QueryString,startP,lenP)
REM get Approver name....
startP=Instr(QueryString, "UserN=")+6
endP=Len(QueryString) +1
lenP = endP-startP
UserN=Mid(QueryString,startP,lenP)
REM Use UserN to format the UserName to be saved into Approver's Field
startN = Instr(1, UserN, "+")
LenN=Len(UserN)
lastname=Mid(UserN,startN + 1,LenN)
firstname=Left(UserN,startN - 1)
REM Final Formatted Approver Name
frmtName$ = firstname + " " + lastname
REM get handle to the Document that we need to modify...
Dim db As Notesdatabase
Dim doc As Notesdocument
Dim session As New NotesSession
Set db = session.CurrentDatabase
Set doc = db.GetDocumentByUNID(docID)
Dim test As String
doc.RemoveItem("Approver")
doc.Approver=frmtName$
doc.RemoveItem("ApproveYN")
doc.ApproveYN="Approved"
doc.RemoveItem("ApproveDate")
doc.ApproveDate= Format(Now(), "mm/dd/yy")
Call doc.Save( True, True )
'Return to document we just approved....
Print "[/" & db.filepath & "/all/" & docID & "?OpenDocument]"
End Sub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Advertisement --
Sophisticated Meets Simple For Document Management
Share. Control. Manage.
Documents, emails, and content in the context of how work is done.
Native to Lotus Domino. The User Experience unseen for Lotus Domino.
Do more with less. Really.
See the possibilities Docova unleashes for Lotus Domino. |
-- Advertisement --
Mark your calendar for in-depth Lotus training, May 12-14, Boston
Join experts and peers May 12-14 in Boston for educational and networking events that deliver real-world Lotus training so you can increase productivity and efficiency in your company, advance your skills, and squeeze the most from your current environment. One registration gets you into THE VIEW's Admin2010 and Lotus Developer2010.
Register by April 10 to save $200. |
|
|
|
|
|
|
|
|
|
|