Tải bản đầy đủ (.pdf) (63 trang)

Lotus Domino Release 5.0 A Developer’s Handbook phần 10 pdf

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (504.64 KB, 63 trang )

you try to move the cursor from the Approval form name field to another
field, as shown in the following figure:
Postopen
Postmodechange
Querysave
Queryclose
Click
Exiting
GetApproverDetails
Globals
You cannot move the cursor without typing a name, because the Exiting
event handler checks the field contents. The Approver button has a Click
event handler which is called by a mouse click trigger. The handler calls
the global routine GetApproverDetails, which displays a dialog box created
by a layout region in the (Approverinfo) form.
The following picture shows an event sequence which occurs when you
create the Application Profile document:
622 Lotus Domino Release 5.0: A Developer’s Handbook
Eclipses shown in gray are not performed, because there is no program
defined for them.
You can use the Domino debugger to see the sequence of real-time events.
For more information on the debugger, see Chapter 10: Programming for
Domino.
Approval Cycle Database: Agent
The approval application requires an agent to deal with the due date expiration
in this example. When the due date has passed and the approver has not
taken any action, the agent processes the approval request depending on the
criteria specified in the application profile for the due date.
A Closer Look at the ApprovalLogic Subform
The following section explains how the ApprovalLogic subform works and
shows you some of the techniques that you can use in designing your own


workflow applications.
We assume here that you have already created your workflow form and have
set up an Application Profile document for it.
Note The LotusScript that follows may not look exactly the same as that in
the template, as it has been formatted for better clarity.
Chapter 16: Domino Ad Hoc Workflow 623
The Major Fields
The ApprovalLogic subform uses many variables to perform its operation,
but there are a few that require particular attention:
Controls which action button (submit, approve,
deny) the current user has clicked and performs the
appropriate functions. This field is not displayed on
the form, but created via the action buttons.
TextAction
Contains the current status of the workflow
document as designated in the Application Profile
document.
TextStatus
Contains the name of the next approver in the
workflow process.
TextNextApprover
Controls who currently has the ability to edit the
document. This is modified in the QuerySave form
event and changed from the original author to the
next approver, and finally to the form
administrator.
AuthorsAuthorizedEditors
Description
F
ield Type

F
ield Name
Creating a New Request
1. To create a new request, the user clicks Create New Request in the
All Requests view. This does three things:
• It builds a list of available Application Profiles from the
ApplicationProfiles view and displays them in a dialog box where
the user can make selections.
• It sets an environment variable, DocType, to the value of the selected
document.
• It composes the selected document.
tList := @DbColumn(""; ""; "ApplicationProfiles"; 1);
List := @If(@IsError(tList); @Return(@Prompt([OK]; _
"Error"; "An error has occurred. Please try again.")); _
tList);
ENVIRONMENT DocType := @Prompt([OKCANCELLIST]; "New _
Request"; "Choose one of the following:"; @Subset(List; _
1); List);
@PostedCommand([Compose]; DocType)
2. When the new workflow document is being created, the LotusScript
PostOpen event is triggered. This code first checks to see if the new
document was created via the Create New Request action button by
checking the value of the environment variable DocType. If the
environment variable does not exist or is blank, then the user is not
allowed to proceed.
624 Lotus Domino Release 5.0: A Developer’s Handbook
If source.IsNewDoc Then
DocType = s.GetEnvironmentString("DocType")
Call s.SetEnvironmentVar("DocType", "None")
If DocType = "None" Or Isempty(DocType) Then

Messagebox "This Document must be created via"
"the Create New Request action."_
& " Please remove it from the Create Menus.", 0,_
"Error"
Continue = False
source.Close
Exit Sub
End If
3. Still within the PostOpen event of the form, LotusScript then finds the
selected Application Profile document and copies all the fields into the
new document being created. If the profile document cannot be found,
the user is informed and is not allowed to continue.
Set view = db.GetView("Application Profiles")\
Set profile = view.GetDocumentByKey(DocType,False)
If profile Is Nothing Then
Messagebox "This application will not execute"&_
"correctly without an application profile.",
0 + 64, "Design Error"
doc.close
Print
Exit Sub
Else
profile.RemoveItem("Form")
Call profile.CopyAllitems(note)
End If
FormAdmin = note.FormAdmin
If FormAdmin(0) = "" Then note.FormAdmin = db.Managers
note.RequesterName = s.CommonUserName
End If
Note The form name is removed from the Application Profile document

before the fields are copied into the new document. If this was not done,
the new document would open using the Application Profile form rather
than the correct workflow form. Although the form field is removed
from the Application Profile document, it is not actually deleted, as the
document is not saved.
4. When a new document is being created, the subroutine
InitializeNewDoc() is called from the forms PostOpen event to
set up the following approver fields: Approver Names (only if not
defined on the Application Profile), Status, Approval Dates, and
Comments.
Chapter 16: Domino Ad Hoc Workflow 625
5. If the list of approvers has been defined in the Application Profile as
being stored in another database, the GetApproverNames() LotusScript
function is executed to retrieve the list of names from the database and
the view specified in the Application Profile.
Note All the fields have been updated in the back-end document,
rather than the UIDocument.
6. At the end of the PostOpen event, the fields in the UI document are
reloaded from the back-end database and then refreshed to reset the
hide-when formulas and computed fields.
source.Reload
source.Refresh
7. When the document is refreshed, the PostRecalc event for the form is
triggered. This event checks whether the current user is trying to edit
the approver list and, if not, exits.
8. The new document is then displayed for the user to complete as required.
In summary, when a new workflow document is created, the PostOpen form
event validates whether the request was generated from the Create New
Request action button by using environment variables. The Application
Profile document is located and its fields copied into the new document, and

the list of approver fields is updated.
Submitting a New Form for Approval
1. When a new workflow document is completed as required, the user
clicks Submit for Approval. This performs the following functions.
• It checks to see if the field ApprName contains the value “Entered
when Submitted.” This value is copied from the Application Profile
document and indicates that the user has not selected the list of
people to send this document to for approval. If they have not made
the selection, then an error message is displayed, and they are
required to return to the document and enter the approvers’ names.
• The action button sets the value of the field Action to the value Submit.
The field SaveOptions is then set to the value “1” to force the
document to be saved and not display the “Do you want to Save this
Document” dialog box to the user.
626 Lotus Domino Release 5.0: A Developer’s Handbook
• The document is then saved and closed.
@If(@Contains(ApprName; "Entered when submitted");
@Return(@Prompt([OK]; PromptTitle; "Please use the \"Edit
Approver List\" button to enter a valid approver
name.")); "");
FIELD Action := "Submit";
FIELD SaveOptions := "1";
@PostedCommand([FileSave]);
@PostedCommand([FileCloseWindow])
2. Before the document is closed, the QuerySave() form event is triggered
by the @PostedCommand([FileSave]) function from the action button.
• This function first sets the global variable DocWasSaved to true so
that the QueryClose event knows to remove some fields.
• It is possible that the user simply wanted to save the document rather
than submit it for approval, so a check is made to see if the document

was saved via the Submit for Approval action button by testing
whether the document contains the Action field:
If Not note.HasItem("Action") Then Exit Sub
• Next, the IdentifyUser() subroutine is called to rebuild the list of
remaining approvers by identifying those approvers that still have a
status of none.
• Using a case statement, the QuerySave event then checks to see which
action button the user clicked (Submit, Approve, or Deny) by testing
the value of the field Action:
Select Case Action(0)
Case "Submit"
If (Status(0) = StatusList(4)) Or (Status(0) = _
StatusList(5)) Then
For n = 1 To 5
note.RemoveItem("ApprStatus")
note.RemoveItem("ApprDate")
note.RemoveItem("ApprComment")
Next
End If
note.RequestDate = dt.LSLocalTime
note.Status = StatusList(2)
SetNextApprover
SetDueDate
SendNotification
Chapter 16: Domino Ad Hoc Workflow 627
• If the action is Submit, the function SetNextApprover() is called to
identify the next approver. This subroutine checks to see which
routing method has been defined (either Serial or Parallel) and sets
the next approver to the first person in the array built from the
IdentifyUser() subroutine:

Select Case RoutingMethod(0)
'If RoutingMethod is serial then NextApprover is simply
'the next in the list
Case "Serial"
If NextAppr > Ubound(ApprName) Then
'StatusQualifier is only used while the approval cycle is
'active
note.RemoveItem("StatusQualifier")
LastApprover = True
Else
NextApprover = ApprName(NextAppr)
note.NextApprover = NextApprover
note.StatusQualifier = "by " & NextApprover
End If
Case "Parallel"
Select Case Action(0)
'If submitting - the next approver is all approvers
Case "Submit"
note.NextApprover = ApproverList
'If Approving - remove CurrentUser from the ApproverList
'and reset NextApprover to the new list
Case "Approve"
ListMax = Ubound(ApproverList)
Redim tmpList(ListMax)
x = 0
For y = 0 To ListMax
If ApproverList(y) <> CurrentUser Then
tmpList(x) = ApproverList(y)
x = x + 1
End If

Next
If x = 0 Then
tmpList(x) = "None"
LastApprover = True
End If
note.NextApprover = tmpList
End Select
End Select
628 Lotus Domino Release 5.0: A Developer’s Handbook
• The subroutine SetDueDate() is called next to set the due dates by
which the approver(s) must authorize the document. For a parallel
workflow document all the due dates for each of the remaining
authorizers are set, and for a serial workflow document, only the
next approver’s due date is set:
Select Case RoutingMethod(0)
'If Parallel - adjust all dates
Case "Parallel"
For n = 0 To ListMax
Adjustment = ApprWin(n)
dt.AdjustDay(Int(Adjustment))
tmpList(n) = dt.LSLocalTime
dt.SetNow
Next
'If Serial - only adjust the date for the Next Approver
Case "Serial"
DueDate = note.DueDate
Redim tmpList(NextAppr)
x = 0
Forall d In DueDate
tmpList(x) = d

If (tmpList(x) = "") Then
tmpList(x) = dt.LSLocalTime
End If
x = x + 1
End Forall
Adjustment = ApprWin(NextAppr)
dt.AdjustDay(Int(Adjustment))
tmpList(NextAppr) = dt.LSLocalTime
End Select
note.DueDate = tmpList
• The SendNotification() subroutine is then called to mail the details of
the workflow document to the next approver. This subroutine creates
a new mail document and sets up the required Domino mail fields in
order for the document to be mailed. If the workflow document is set
up as a serial document, all approvers are sent an e-mail, if it is set up
as a parallel workflow document, only the next approver is e-mailed:
Select Case RoutingMethod(0)
'If it is Serial - mail gets sent to the NextApprover
Case "Serial"
SendTo = NextApprover
Recipient = NextApprover
'If it is Parallel - mail gets sent to all approvers
Case "Parallel"
SendTo = ApproverList
Chapter 16: Domino Ad Hoc Workflow 629
Recipient = "all Approvers"
End Select
Subject = WorkflowObject(0) & " requires your approval by
" & Format(DueDate(NextAppr), "Long Date")
maildoc.DueDate = Format(DueDate(NextAppr), "Long Date")

maildoc.FlowStatus = "Please follow this doclink to the "
& WorkflowObject(0) & " and either approve or deny it."
'Put a doclink in the Body field and populate the other
fields on the Bookmark mail form
Call rtitem.AppendDocLink(note, "Doclink to " &
WorkflowObject(0))
maildoc.InheritedDbTitle = db.Title
maildoc.Form = "Bookmark"
maildoc.SendTo = SendTo
maildoc.Subject = subject
• The mail message is then sent:
Call maildoc.Send (False)
• Finally, the UI document is then reloaded from the back-end
document to update the UI document fields.
3. After the mail item is sent and the QuerySave event has finished, the
@PostedCommand([FileCloseWindow]) function is performed. This
triggers the QueryClose form event. This event cleans up any temporary
fields that were used in the document:
'Remove the Action field and any field that begins with d_
'This includes all temporary fields and all display only
'fields
'(a back-end save will save computed for display fields
'unless you do this)
note.RemoveItem("Action")
ItemList = note.Items
Forall n In ItemList
If Left(n.Name, 2) = "d_" Or Left(n.Name, 2) = "D_"
Then n.Remove
End Forall
4. The QueryClose event then executes the ResetAuthorNames()

subroutine. This subroutine removes the document author from
the AuthorizedEditors Authors field and adds the name of the
next approver:
Select Case NewStatus(0)
'If approvals are done - the FormAdmin is the only editor
Case StatusList(6), StatusList(7)
note.AuthorizedEditors = FormAdmin(0)
'If approvals are not started - the Requester is the only
'editor
Case StatusList(0), StatusList(1)
630 Lotus Domino Release 5.0: A Developer’s Handbook
note.AuthorizedEditors = RequesterName(0)
Case Else
tmpList(0) = FormAdmin(0)
x = 1
Forall n In NextApprover
tmpList(x) = n
x = x + 1
End Forall
note.AuthorizedEditors = tmpList
End Select
5. The document is then finally closed.
In summary, when Submit is clicked, the field Action is set to Submitted and
the QuerySave event is triggered. The QuerySave event sets up a list of
remaining approvers, sets the next due date and sends an e-mail to the next
approver(s). Finally, the QueryClose event cleans up the document and sets
the author of the document to be the next approver.
Approving a Request
When an approver clicks Approve, the following events occur:
1. On the Approve action button, the value of the field Action is set to

Approve and a dialog box is displayed to enable the approver to enter
any comments. The document is then saved and closed:
@Command([EditDocument]; "1");
FIELD Action := "Approve";
FIELD SaveOptions := "1";
@If(CommentsAllowed = "Yes";
@DialogBox("EnterComments"; [AutoVertFit] : [AutoHorzFit]);
PromptTitle);
@PostedCommand([FileSave]);
@PostedCommand([FileCloseWindow])
2. The @PostedCommand([FileSave]) command triggers the QuerySave
form event. The QuerySave event updates the current approver status,
date and comment fields:
Select Case Action(0)
Case "Approve"
'Set approval status for the current approver
ApprStatus = note.ApprStatus
ApprStatus(CurrentApprover) = StatusList(3)
note.ApprStatus = ApprStatus
'Set approval date for the current approver
ApprDate = note.ApprDate
ApprDate(CurrentApprover) = dt.LSLocalTime
note.ApprDate = ApprDate
'Set comment value for the current approver
Chapter 16: Domino Ad Hoc Workflow 631
NewComment = note.d_ApprComment
ApprComment = note.ApprComment
ApprComment(CurrentApprover) = NewComment(0)
note.ApprComment = ApprComment
'Set the next approver, the expiration and send mail to the

appropriate person(s)
SetNextApprover
3. The QuerySave event then executes the SetNextApprover() subroutine.
This subroutine iterates through the remaining approvers to select the
next approver or, if this is the last approver, sets the LastApprover
variable to be true:
Case "Approve"
ListMax = Ubound(ApproverList)
Redim tmpList(ListMax)
x = 0
For y = 0 To ListMax
If ApproverList(y) <> CurrentUser Then
tmpList(x) = ApproverList(y)
x = x + 1
End If
Next
If x = 0 Then
tmpList(x) = "None"
LastApprover = True
End If
note.NextApprover = tmpList
End Select
4. If the current approver is the last approver, then the field
NextApprover is removed from the document:
If LastApprover Then
If Action(0) = "Approve" Then note.Status = StatusList(7)
note.RemoveItem("NextApprover")
End If
5. Returning to the QuerySave event, an e-mail is then sent by executing the
SendNotification() subroutine if the selected routing method is set up as

serial or if this is the last approver. If the routing method was set up as
parallel, then each person would already have been sent an e-mail when
the document was originally submitted:
If RoutingMethod(0) = "Serial" Then
If Not LastApprover Then SetDueDate
End If
If RoutingMethod(0) = "Serial" Or LastApprover Then
SendNotification
632 Lotus Domino Release 5.0: A Developer’s Handbook
6. The SendNotification() subroutine first checks to see if this is the last
approver. If so, the document originator is sent an e-mail informing
them that their workflow request was successful. If there are more
approvers, then the next approver is sent an e-mail.
7. The QuerySave event then finishes and the Approve action button
@Command([FileCloseWindow]) is executed, which triggers the
QuerySave form event. Again, this subroutine cleans up any temporary
variables and sets the document author to that of the next approver.
In summary, when an approver clicks Approve, the current approver fields
are updated, the next approver is identified, and an e-mail is sent either to
the next approver or to the document originator if there are no remaining
approvers. Finally, if there are further approvers, the AuthorizedEditors
field is updated to the name of the next approver.
Denying a Request
When an approver denies a request the following events occur:
1. The Deny action button sets the value of the Action field to Deny,
prompts the approver for the reason for denying the request, and saves
and closes the document:
@Command([EditDocument]; "1");
FIELD Action := "Deny";
FIELD SaveOptions := "1";

@If(CommentsAllowed = "Yes";
@DialogBox("EnterComments"; [AutoVertFit] : [AutoHorzFit]);
PromptTitle);
@PostedCommand([FileSave]);
@PostedCommand([FileCloseWindow])
2. When the @PostedCommand([FileSave]) command is executed, the
QuerySave form event is triggered. When the action is set to Deny, the
QuerySave event sets the document status field to Deny, removes the
NextApprover field, and e-mails the document originator by calling the
SendNotification() subroutine.
3. The @PostedCommand([FileCloseWindow]) command is then executed.
This triggers the QueryClose form event which removes any temporary
fields from the document and calls the ResetAuthorNames() subroutine.
4. The ResetAuthorNames() subroutine sets the value of the document
author field, AuthorizedAuthors, to the form administrator designated
in the Application Profile document.
Chapter 16: Domino Ad Hoc Workflow 633
Summary
In this chapter we have discussed how to create, set up, and use the
Approval Cycle template. We have also looked in detail at the LotusScript
code used within the ApprovalLogic subform to better understand how an
ad hoc workflow application can be designed.
634 Lotus Domino Release 5.0: A Developer’s Handbook
Domino uses URLs to access servers, databases, and other components of a
Web site, and display them to Web users. Knowing Domino URL commands
allows you to design links or enter commands directly into a browser to
navigate a Domino site or to reach specific components quickly.
Domino URL Command Syntax
Domino URL commands have the following syntax:
http://Host/Database/DominoObject?Action&Arguments

where:
Host
DNS entry or an IP address
Caution You cannot use the Domino Server name unless it has a
DNS entry.
Database
Database can be one of the following:
• The database file name with the path relative to notes\data.
• The database Replica ID.
DominoObject
A Domino construct (a view, document, form, navigator, agent, etc.)
Action
The desired operation on the specified Notes object, for example,
?OpenDatabase, ?OpenView, ?OpenDocument, ?EditDocument,
?OpenForm, ?ReadForm and so on.
Arguments
A qualifier of the action. For example, Count = 10 combined with the
?OpenView action limits the number of rows displayed in a view to 10.
Appendix A
Domino URLs
635
Use the following guidelines when working with Domino URLs:
1. Special identifiers used in Domino URL commands include:
$defaultView, $defaultForm, $defaultNav, $searchForm, $file, $icon,
$help, $about. These special identifiers are described in the following
sections of this appendix.
2. DominoObject can be any of the following:
• For a database, it is the database name or replicaID itself.
• For other objects, the Domino object name or alias, universal ID,
NoteID or special identifier. For example, to specify a view in a URL,

you can use any of the following: the view name, view universal ID,
view Note ID, or $defaultView.
A Domino object name and universal ID are identical in all replicas of
a database, but the NoteID will probably change in database replicas.
Therefore, it is best to use the Domino object name or universal ID
in URLs.
Note We will not show NoteID and universal ID in this section.
3. Action can be explicit or implicit.
• Examples of explicit actions include ?OpenServer, ?OpenDatabase,
?OpenView, ?OpenDocument, ?OpenForm, and ?EditDocument.
• Examples of implicit actions include ?OpenDocument, ?OpenView,
and ?OpenDatabase.
• If you do not specify an action, Domino defaults to the ?Open action.
4. Append the Login argument to any Domino URL to require user
authentication.
Because URLs may not contain spaces, use the + (plus sign) as a
separator. For example:
/>5. Separate arguments with & (ampersands). For example:
/>andView
6. Separate hierarchical names with / (slashes). For example, to open a view
named Docs\By Author in a database named Discussion, enter:
/>636 Lotus Domino Release 5.0: A Developer’s Handbook
Opening Servers, Databases, and Views
The following commands access servers, databases, views, About documents,
help documents, and database icons.
OpenServer
Syntax:
http://Host
Example:
/>OpenDatabase

Syntax:
http://Host/DatabaseFileName?OpenDatabase
http://Host/DatabaseReplicaID?OpenDatabase
Examples:
/> /> />OpenView
Syntax:
http://Host/Database/ViewName?OpenView
http://Host/Database/$defaultview?OpenView
Note ViewName can be also an alias of the view.
Examples:
/> />Arguments (Optional)
Append optional arguments to refine the URL. Combine any of the
following arguments for the desired result.
• Start = n Where n is the row number to start with when displaying the
view. The row number in a hierarchical view can include subindexes;
for example, Start=3.5.1 means thst the view will start at the third main
topic, subtopic 5, document 1.
• Count = n Where n is the number of rows to display.
• ExpandView Displays the view in expanded format.
Appendix A: Domino URLs 637
• CollapseView Displays the view in collapsed format.
• Expand = n Where n is the row number to display in expanded format in
a hierarchical view. Do not combine this argument with the ExpandView
or CollapseView0 arguments.
• Collapse = n Where n is the row number to display in collapsed format
in a hierarchical view. Do not combine this argument with the
ExpandView or CollapseView arguments.
• StartKey= string Open a view starting from the first document that
matches the key. The key is selected on the first sorted column.
Examples:

/>iew
/>&Count=15
Note To open the first document in a view, use keyword $First and the
following syntax: http://host/database/view/$First.
OpenAbout
Use the OpenAbout command to access the “About database” document.
Syntax:
http://Host/Database/$about?OpenAbout
Examples:
/>OpenHelp
Use the OpenHelp command to access the Help document.
Syntax:
http://Host/Database/$help?OpenHelp
Examples:
/>OpenIcon
Use the OpenIcon command to access the database icon.
Syntax:
http://Host/Database/$icon?OpenIcon
Examples:
/>638 Lotus Domino Release 5.0: A Developer’s Handbook
Login Argument
Append the Login argument to any Domino URL to force user authentication,
regardless of the database access control list. This ensures that anonymous
Web users who weren’t initially prompted for a name and password when
they entered the site, are required to supply a name and password to complete
tasks that require user identity.
Note Do not use this argument to let a Web user switch login. In fact if a
user has already logged in with a certain UserID and Password, the login
argument will be ignored. The only way to re-login as a new user is to close
and then restart the browser.

Syntax:
You can use this argument with any URL, but the most common are:
http://Host?OpenServer&Login
http://Host/Database?OpenDatabase&Login
Examples:
?OpenServer&login
/>Opening Framesets, Pages, Forms, Navigators, and Agents
The following commands open framesets, pages, forms, navigators, and
agents in a database.
OpenFrameset
Syntax:
http://Host/Database/FramesetName?OpenFrameset
Note FramesetName can be also an alias of the frameset.
Examples:
/>OpenPage
Syntax:
http://Host/Database/PageName?OpenPage
Note PageName can be also an alias of the page.
Examples:
/>Appendix A: Domino URLs 639
OpenForm
Syntax:
http://Host/Database/FormName?OpenForm
http://Host/Database/$defaultform?OpenForm
Note FormName can be also an alias of the form.
Examples:
/> />Arguments (Optional):
ParentUNID = The Universal ID of the parent document, to respond to or to
inherit from. Remember that if you are composing a response document or
you want to inherit formulas from another document on the Web, you

cannot select the parent document.
Syntax for using this argument:
http://Host/Database/FormUniversalID?OpenForm&ParentUNID
Examples:
/>c9e0?OpenForm&ParentUNID=6bc72a92613fd6bf852563de001f1a25
Note You can also use the ?OpenRead or ?ReadForm command to open a
form only in read mode. This is useful when you don’t want to display the
submit button.
OpenNavigator
Syntax:
http://Host/Database/NavigatorName?OpenNavigator
http://Host/Database/$defaultNav?OpenNavigator
Examples:
/> />Note $defaultNav opens the folder navigator in a database.
OpenAgent
Syntax:
http://Host/Database/Agentname?OpenAgent
Examples:
/>nt
640 Lotus Domino Release 5.0: A Developer’s Handbook
Opening, Editing, and Deleting Documents
The following commands manipulate documents in a database:
OpenDocument
Syntax:
http://Host/Database/View/DocumentKey?OpenDocument
DocumentKey contains the contents of the first sorted column in the
specified view. For more information, see the section on opening documents
by key later in this chapter.
Note The View is a necessary parameter because Domino uses the Form
Formula of a view to determine the form to use when displaying the document

(either using a Notes Client or a browser). If this formula is set to nothing,
Domino uses the form written in the “Form” field of the document.
Examples:
/>ument
EditDocument
Syntax:
http://Host/Database/View/Document/?EditDocument
Example:
/>ument
DeleteDocument
Syntax:
http://Host/Database/View/Document?DeleteDocument
Example:
/>ocument
CreateDocument
The CreateDocument command is used as the POST action of an HTML
form. When the user submits a form, Domino obtains the data entered in the
form and creates a document.
Syntax:
http://Host/Database/Form/?CreateDocument
Example:
/>Appendix A: Domino URLs 641
SaveDocument
The SaveDocument command is used as the POST action of a document
being edited. Domino updates the document with the new data entered in
the form.
Syntax:
http://Host/Database/View/Document?SaveDocument
Example:
/>82d0/4c95c7c6700160e2852563df0078cfeb?SaveDocument

Opening an Anchor Link
As seen in the previous section on Domino Links, a new syntax exists for
opening a document at a specified area of its text.
Syntax:
http://Host/Database/View/Document?OpenDocument#AnchorLabel
Example
http://localhost/RedBook.nsf/66aa0bd809ee8316852564d8004e7ddc/5
03d4ee771078042852564e400598a8e?OpenDocument#Paragraph+3
The Anchor label is created when you build the anchor inside the linked
document. If no name has been entered for that link, a default number is
added (Example: “#_0”).
Opening Documents by Key
The following commands allow you to open a document by key, or to
generate a URL to link to a document by key.
Using Domino URLs to Access a Document
To open a document by key, create a sorted view with the sort on the first
key column. You then can use a URL to open the document:
Syntax:
http://Host/DatabaseName/View/DocumentName?OpenDocument
Example:
/>OpenDocument
Where View is the name of the view, and DocumentName is the string, or
key, that appears in the first sorted or categorized column of the view. Use
this syntax to open, edit, or delete documents, and to open attached files.
642 Lotus Domino Release 5.0: A Developer’s Handbook
Domino returns the first document in the view with a column key that
exactly matches the DocumentName.
There may be more than one matching document; Domino always returns
the first match. The key must match completely for Domino to return the
document. However, the match is not case-sensitive or accent-sensitive.

Note that the view can be a view Note ID, UNID, or view name. In addition,
the implicit form of any of these commands will work when appropriate.
(EditDocument and DeleteDocument must be explicit commands).
Advantages of Using Keys Instead of Universal ID
Let’s suppose that the following two URLs refer to the same document,
which is the personal document of “Jay Street” (for instance):
/>Registered+Users/Jay+Street?OpenDocument
/>a0cefa69d38ad9ed8525631b006582d0/
4c95c7c6700160e2852563df0078cfeb?OpenDocument
The first URL is, of course, much more understandable than the second URL
and therefore, easier to remember. However, this is not the only advantage
of using keys to refer to Domino objects.
Imagine that the “Jay Street” document has been deleted and replaced by a
new copy. The reasons for using this event might be, for example, where all
documents of that kind are deleted and rebuilt every night by an agent that
takes updated data from an external data source. In this situation, the first
URL continues to reference the “Jay Street” document, while the second URL
fails because the Universal ID of the new document will be different from
the former. This means that if a user has stored the first URL as a bookmark
he will have no problem finding his document again, and so will avoid
repeated searches.
However, you should also consider the following implications of using URL
by keys:
• A developer must use @formulas to calculate every URL using keys, and
must hide or inhibit all the URLs automatically generated by Domino.
This means that you don’t need to copy and paste links to Domino
objects.
• The access to documents is faster when using Universal ID than using
keys, as the server must read the view index to reach the document
when using keys.

Appendix A: Domino URLs 643
Opening Image Files, Attachments and OLE Objects
The following commands open files and objects within a document:
OpenElement
Use the ?OpenElement command to access file attachments, image files, and
OLE objects. This is very useful when writing passthru HTML; for example,
when you need to display an image that is attached into another Notes
document you can use the URL described here.
Using OpenElement with File Attachments
Syntax:
http://Host/Database/View/Document/$File/Filename?OpenElement
http://Host/Database/View/Document/$File/
InternalFileName/Filename?OpenElement
Example:
/>By+Part+Number/SN156/$File/spec.txt?OpenElement
If more than one attached file has the same name, the URL includes both the
internal file name as well as the external name. Since the internal file name is
not easily determined, make sure that all attached files have unique names.
Domino treats all file attachment OpenElement commands as implicit
commands, because some browsers require that the URL ends with the
attached file name.
Using OpenElement with Image Files
It is used to retrieve an image that is an imported image into a Notes field.
Syntax:
http://Host/Database/View/Document/FieldName/
FieldOffset?OpenElement&FieldElemFormat=ImageFormat
FieldOffset is represented by xx.yy, where xx is the field number, and yy is the
byte offset into the field.
ImageFormat is either GIF or JPEG. If the FieldElemFormat is not entered,
Domino assumes that the image file format is GIF.

To see an example, try to import a GIF image into a RichText field and
launch the preview in browser. Next, look at the HTML source for that
image. You should find something like this:
<IMG SRC="/database/view/document/FieldName/xx.yy
?OpenElement&FieldElemFormat=GIF>
644 Lotus Domino Release 5.0: A Developer’s Handbook
Using OpenElement with OLE Objects
Syntax:
http://Host/Database/View/Document/FieldName/
FieldOffset/$OLEOBJINFO/FieldOffset/obj.ods?OpenElement
Note The current URL syntax for referencing images and objects in Notes
documents — specifically the FieldOffset — makes it impractical to create
these URLs manually. As an alternative, you may paste the actual bitmap or
object in place of the reference, create URL references to files stored in the
file system, or attach the files to the documents.
Searching for Text with Domino Search URLs
The following commands allow you to search a Domino site or to search
individual databases within a Domino site:
SearchSite
Syntax:
http://Host/Database/[$SearchForm]?SearchSite[ArgumentList]
Where $SearchForm and ArgumentList are optional arguments. The special
identifier $SearchForm indicates that Domino will present a search site form
for search input. If this identifier is provided, ArgumentList is ignored.
Examples:
/> />Query=product+info+requests;1;;0;FALSE
SearchView
Syntax:
http://Host/Database/View/[$SearchForm]?SearchView[Argument
List]

Where $SearchForm and ArgumentList are optional arguments.
The special identifier $SearchForm indicates that Domino will present a
search view form for search input. If this identifier is provided, the
ArgumentList is ignored.
Examples:
/>$SearchForm?SearchView
/>?SearchView&Query=PC156;3;;0;TRUE;
Appendix A: Domino URLs 645
Argumentlist (Optional)
The ArgumentList must contain the Query argument; in addition, it may
contain any or all of the other arguments.
• Query = the search string
• Count=[n]
• SearchFuzzy=[TRUE, FALSE], default = FALSE
• SearchOrder=[1,2,3] default = 1.
• 1 = “By Relevance”
• 2 = “By Date Ascending”
• 3 =“By Date Descending”
• SearchMax=[n], 0 default= 0 (meaning all)
• SearchWV=[TRUE, FALSE], default = TRUE
• Start=[n]
• OldSearchQuery
Repeats the last query.
Note The SearchThesaurus argument is ignored by the R5.0 search
machine.
646 Lotus Domino Release 5.0: A Developer’s Handbook

×