|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 --
Learn Notes and Domino 8 at your place and pace!
Learn Notes and Domino in your office and/or home! TLCC's highly acclaimed distance learning courses for users, developers, and admins will enhance your career and your resume.
The many included activities and demos will make you a pro! Expert instructor help is a click away.
Click here to try a FREE demo course!! |
-- 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. |
|
|
|
|
|
|
|
|
|
|