Email:   
Home
In This Issue
EasyPrint
Click here for the RSS feed's XML code. This is not a browser URL.
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




[ Prev | Next ]

ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
-- Advertisement --

AUTOMATE LOTUS NOTES USER ID MANAGEMENT
ID Manager 4.5 from HELP Software provides a new level of automaton for managing Lotus Notes IDs. ID Manager lets Lotus Notes administrators get out of the business of creating and managing user IDs. Use our ROI calculator to see how quickly ID Manager will pay for itself.

Learn more about HELP Software products
-- Advertisement --

Get in the Spotlight! Teamstudio Spotlight Awards 2009
For the second year, Teamstudio is holding the Teamstudio Spotlight Awards Contest to recognize developers of the Notes community for their most remarkable Notes applications! Winners will be announced at Lotusphere 2009 January and featured in DominoPower in the month of February. Prizes to include:

1st Prize: Your choice of one configured software product with installation at one site, Teamstudio's complete suite of tools for one user and an iPod Touch.
2nd Prize: Teamstudio's complete suite of tools.
3rd Prize: One tool of your choice.

For more information on how to enter, click here!

Copyright © 1998-2008, ZATZ Publishing. All rights reserved worldwide.
Editor's Login