Search DominoPower's 11,420 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
Application development, William Shatner, and the origin of the universe
The (near) future of Sametime, Quickr, Connections, and Symphony
Inside the IBM Innovations lab
Lotusphere 2010: Hot fixes and cool news for Notes, Domino, and LotusLive
Lotusphere 2010: mobility and collaboration
2010: A Lotusphere of change
Five trends for 2010
Latest Lotus Headlines
New Notes/Domino Technotes published about Chile's extended daylight saving time
SnnT: How to prevent Google from listing your Sametime Server
How to send someone an email that shows your calendar availability
"The collection has become invalid"
More XPages onclick event weirdness...
Domino 8.5.1 Fix Pack 1 Interim Fix 1 (8.5.1 FP1 IF1) - DAOS Fixes
Domino Designer 8.5 Tip: Where Working Sets Are Stored
>> Read all the news
More from the ZATZ journals
Computing Unplugged: Make Mafia Wars an offer it can't refuse
David Gewirtz Online: CNN commentary and analysis
OutlookPower: Removing an Office installation that doesn't want to go away
-- 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 --

Integrate your Notes Applications with Microsoft Office and Symphony
Integra for Notes Integrates Microsoft Office and/or IBM Lotus Symphony
Requires NO change to the design of the appliation or Installations of DLL's and EXE's
  • Integra is a ready to use solution, enhance static reports with Excel data analysis, pivot tables, macros
  • User friendly aproach, using a point and click access to features
  • Reports from any Lotus Notes databases
  • Runs reports through a Notes client, web browser and scheduled basis
  • Allows use of LotusScript for advanced data manipulation
  • Enables self service reporting capabilities to end-users


Learn more at www.integra4notes.com.
ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
Copyright © 1998-2010, ZATZ Publishing. All rights reserved worldwide.
Editor's Login