Search DominoPower's 10,675 Lotus-related article archive 
Home
EasyPrint
News details Click here for the RSS feed's XML code. This is not a browser URL.
Articles-only Click here for the RSS feed's XML code. This is not a browser URL.
Twitter Feed Click here for the Twitter feed.
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


« Previous  ·  1  ·  2  ·  3  ·  4  ·  Next »
Other articles you might like
Home > Lotus Technologies > LotusScript (64 articles)
   When the debugger won't debug hidden code that isn't hidden
   What to do if the LotusScript debugger won't single-step over code
   Little known traps about Lotus Notes fields
Get Weekly Email Updates
Subscribe to our regular weekly email newsletter. It's packed with tips, reviews, deep analysis, and the latest news.
 
Recent DominoPower Articles
What to look for in a Domino-based document management solution
Understanding Domino.doc end-of-life options
When the debugger won't debug hidden code that isn't hidden
What to do if the LotusScript debugger won't single-step over code
Top 10 ways to launch and build a Lotus consulting practice (with a little help from the Beatles)
Troubleshooting an OpenSuse Notes install
Incident report: denial of service attack against ConnectedPhotographer.com
Latest Lotus Headlines
SnTT - Enabling ALL the bells and whistles!
Tivoli Data protection causes Domino to crash
Fun when running DB2 CLP scripts
Introducing Flippr, the easy way to admin Quickr
DXL and fake security
Using search forms in IBM Workplace Collaborative Learning 2.7
Schmidt, Freed, and Gering on the OVF Toolkit
>> Read all the news
More from the ZATZ journals
Computing Unplugged: Eight steps to successful and reliable home backups
David Gewirtz Online: CNN commentary and analysis
OutlookPower: Can Outlook run when it's not running (and other mysteries)?
-- 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.
ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
Copyright © 1998-2009, ZATZ Publishing. All rights reserved worldwide.
Editor's Login