The most important part in Lotus Notes

Source: Internet
Author: User
Tags delete key

Lotus Notes Most Important Part
Evaluate () executes a Lotus Formula language in the script and returns the value returned by the formula language.
3. (@ modified, @ date, @ weekday, @ today, @ adjust, @ Yesterday ). This example is modified based on the previous example. The weekend is skipped when "yesterday" is specified. If today is Monday, Y is set to today's date minus 3 days; otherwise, it is set to yesterday's date. Replace @ yesterday with Y to test @ modified date.
D: = @ date (@ modified );
Y: = @ if (@ weekday (@ today) = 2; @ adjust (@ today; 0; 0;-3; 0; 0; 0); @ Yesterday );
Field viewstatus: = @ if (D = @ today; "today"; D = y; "yesterday"; "old ");
Select @ All
How to determine whether an RTF is null
Function isrtfnull (rtfield as string) as integer
On Error goto errhandle
Dim workspace as new notesuiworkspace
Dim uidoc as notesuidocument
Set uidoc = workspace. currentdocument
Currentfield = uidoc. currentfield
Call uidoc. gotofield (rtfield)
Call uidoc. selectall
Call uidoc. deselectall
If currentfield <> "" then
Call uidoc. gotofield (currentfield)
End if
Isrtfnull = false
Exit Function
Errhandle:
Select case err
Case 1, 4407
'The deselectall line generated an error message, indicating that the rich text field does not contain anything
If currentfield <> "" then
Call uidoc. gotofield (currentfield)
End if
Isrtfnull = true
Exit Function
Case else
'For any other error, force the same error to cause LotusScript to do the error handling
Error err
End select
End Function
How to return a data type
Declarations
Class returnobj
Private m_stname as string
Private m_sttype as string
Property get nameval as string
Nameval = m_stname $
End Property
Property get typeval as string
Typeval = m_sttype $
End Property
Sub new (arg_stname $, arg_sttype $)
M_stname = arg_stname $
M_sttype = arg_sttype
End sub
End Class
Function Test () as returnobj
Set test = new returnobj ("name", "type ")
End Function
Initialize
Dim VaR
Set Var = test ()
Msgbox (var. nameval)
How to determine whether a file directory exists
If dir $ (dirname, attr_directory) = ""
Then 'Directory does not exist
Else
'Directory does exist
End if
How to run proxy in Lotus script
Set S = Createobject ("notes. notessession"
Set DB = S. getdatabase ("", "DB. nsf"
Set a = dB. getAgent ("someagent"
Call S. setenvironmentvar ("agentdocid", "ABCD"
Call a. Run
How to obtain the file path of the current database
Public Function
Getdatabasepath (dB as notesdatabase) as string
Dim position as integer
Position = instr (db. filepath, DB. filename)
Getdatabasepath = left (db. filepath, position-1)
End Function
How to compare two date fields
Mdate1v = Document. datefield1 (0)
Mdate2v = Document. datefield2 (0)
If mdate1v <mdate2v then
Msgbox "date 1 less then date 2"
Else
Msgbox "date 2 less then or equal to date 1"
End if
@ Mailsend in script
Function sendmailmemo (sendto as string ,_
Cc as string ,_
BCC as string ,_
Subject as string ,_
Body as string ,_
Linkto as notesdocument) as integer
On Error goto errorhandler
Dim maildb as new notesdatabase ("",""
Dim maildoc as notesdocument
Dim rtitem as notesrichtextitem
Call maildb. openmail
If (maildb. isopen = false) then call maildb. Open ("",""
Set maildoc = maildb. createdocument
Maildoc. form = "memo"
Maildoc. sendto = sendto
Maildoc. Cc = cc
Maildoc. bcc = BCC
Maildoc. Subject = subject
Set rtitem = maildoc. createrichtextitem ("body"
Call rtitem. appendtext (Body)
If not (linkto is nothing) then
Call rtitem. addnewline (2)
Call rtitem. appenddoclink (linkto, "double-click to open document"
End if
Call maildoc. Send (false)
Sendmailmemo = true
Exit Function
Errorhandler:
Print "error" & STR $ (ERR) & ":" & error $
Resume theend
Theend:
Sendmailmemo = false
End Function
How to Use LotusScript to start attachments
First Use The embeddedobjects class detaches an attachment from a temporary folder and runs it using shell statements.
How to Create a name domain, reader domain, and author domain in Lotus script
Create a "specialtype" Name field
Dim variablename as new notesitem (notesdocument, name $, value [, specialtype %])
Create an "author" author domain
Dim tauthor as new notesitem (Doc, "author", auths, authors)
Tauthor. issummary = true
How to automatically modify the reply document after modifying the master document
Sub querysave (source as notesuidocument, continue as variant)
Dim collection as notesdocumentcollection
Dim doc as notesdocument
Dim form, parentstatus, status as string
Set Doc = source. Document
Set collection = Doc. Responses
Set Doc = collection. getfirstdocument
Parentstatus = source. fieldgettext ("status"
While not (Doc is nothing)
Form = Doc. getitemvalue ("form" (0)
Status = Doc. getitemvalue ("status" (0)
If (form = "task" and (status <> parentstatus) then
Call Doc. replaceitemvalue ("status", parentstatus)
Call Doc. Save (true, false)
End if
Set Doc = collection. getnextdocument (DOC)
Wendend
Sub
How to get it in time Service Time of the device
Dim doc as notesdocument
Set Doc = serverdb. createdocument
Createdate = Doc. Created
............
Do not save this document
In Lotus scripts, how does one add a carriage return to the string?
"AAA" + CHR (10) + "BBB"
How to block users from deleting objects with the delete key
Use the following statement in querydocumentdelete of the database script.
Continue = false
LotusScript is fully object-oriented Programming Language . It uses predefined classes and Domino Interface . Domino monitoring users Code And automatically include Domino Class definition.
It is best to use LotusScript to access existing objects. For example, you can change the values in a document based on the values of other documents. LotusScript provides Function For example, the ability to operate the database access control list (ACL.
The key to writing a script is to take an object and view its attributes. Therefore, you must learn to read the script help provided by notes. Below are some script examples I have collected. It is usually relatively skillful. Program To learn how to write a general script, download the LotusScript learning library!
Lotus script is a fully object-oriented programming language. It uses predefined classes and Domino interfaces. Domino monitors the compilation and loading of user code and automatically includes Domino class definitions.
It is best to use LotusScript to access existing objects. For example, you can change the values in a document based on the values of other documents. Lotus script provides some functions that are not available in formulas, such as the ability to operate the database access control list (ACL.
The key to writing a script is to take an object and view its attributes. Therefore, you must learn to read the script help provided by notes. Below are some script examples I have collected. Generally, it is a relatively skillful program. To learn about writing General scripts, please download the LotusScript learning library!
How to identify the data types in the domain?
Dim item as notesitem
Set item = Doc. getfirstitem ("item"
If item. type = numbers then
End if
How can I determine if there is no document in the view?
Set Doc = VW. getfirstdocument ()
If Doc is nothing then
End if
How do I put the query results in a folder?
Put the search result in a folder named newfolder and jump to the folder.
Sub click (source as button)
Dim Docs as notesdocumentcollection
Dim doc as notesdocument
...........
Q = Doc. Query (0)
Set docs = dB. ftsearch (Q, 0)
Call docs. putallinfolder ("newfolder ")
Call W. opendatabase ("", "", "newfolder"
End sub
How do I delete all private views in the database?
Dim session as new notessession
Dim dB as notesdatabase
Dim doc as notesdocument
Set DB = session. currentdatabase
Forall I in db. Views
Set Doc = dB. getdocumentbyunid (V. universalID)
'The local view is Composition To obtain some attributes of the view.
Viewflag = Doc. getitemvalue ("$ flags"
If viewflag (0) = "pyv" then
In 'view attributes, $ flags is a private view with "pyv.
Call I. Remove
End if
End forall
In notes, how does one call the process in the ODBC data source?
The following is a script code that uses ODBC to call the ACCESS database (database ).
Dim session as new notessession
Dim con as new odbcconnection
Dim qry as new odbcquery
Dim result as new odbcresultset
Set qry. Connection = con
Set result. query = qry
Con. connectto ("Database"
Qry. SQL = "select * from database"
Result. Execute
If result. isresultsetavailable then
Do
Result. nextrow
Id = result. getvalue ("ID", ID)
Loop until result. isendofdata
Result. Close (db_close)
Else
MessageBox "cannot get result set for assetdata"
Exit sub
End if
Con. Disconnect
End sub
Refresh the current document from the background?
Close the current document before opening it.
Set doc=uidoc.doc ument
......
Call uidoc. Save ()
Call uidoc. Close ()
Set uidoc = ws. editdocument (DOC)
Obtain the selected document in the current view?
You can use the unprocesseddocuments attribute of notesdatabase.
Dim session as new notessession
Dim dB as notesdatabase
Dim collection as notesdocumentcollection
Set DB = session. currentdatabase
Set collection = dB. unprocesseddocuments
Unprocesseddocuments is actually very useful
Exchange data in notes and Excel
Dim session as new notessession
Dim dB as notesdatabase
Dim view as notesview
Dim doc as notesdocument
Dim excelapplication as Variant
Dim excelworkbook as Variant
Dim excelsheet as Variant
Dim I as integer
Set excelapplication = Createobject ("Excel. Application"
Excelapplication. Visible = true
Set excelworkbook = excelapplication. workbooks. Add
Set excelsheet = excelworkbook. worksheets ("sheet1"
Excelsheet. cells (1, 1). value = "name"
Excelsheet. cells (1, 2). value = "Age"
I = 1
Set DB = session. currentdatabase
Set view = dB. getview ("ABC"
Set Doc = view. getfirstdocument
While not (Doc is nothing)
I = I + 1
Excelsheet. cells (I, 1). value = Doc. classcategories (0)
Excelsheet. cells (I, 2). value = Doc. Subject (0)
Set Doc = view. getnextdocument (DOC)
Wend
Excelsheet. Columns ("A: B". Select
Excelsheet. Columns ("A: B". entirecolumn. autofit
Excelworkbook. saveas ("script content"
Excelapplication. Quit
Set excelapplication = nothing
How can I view all documents?
Dim dB as new notesdatabase ("Ankara", "current/projects. nsf ")
Dim view as notesview
Dim doc as notesdocument
Set view = dB. getview ("Open/by due date ")
Set Doc = view. getfirstdocument
While not (Doc is nothing)
....................
Set Doc = view. getnextdocument (DOC)
Wend
How to call a formula in scipt
For example, if we want to get the common name of the server name and use @ name () in the script, assume that the server variable can get the server name and run the formula using evaluate in the script, for example: servername = evaluate ("@ name ([CN]; server )"
How to Use the script proxy to get CGI variables
Dim session as new notessession
Dim doc as notesdocument
Set Doc = session. documentcontext
MessageBox "user =" + Doc. remote_user (0)
How can I use WIN32API to hide a menu?
1. Declarations:
Declare function getactivewindow lib "user32.dll" () as long
Declare function setmenu lib "user32.dll" (byval hmenu as long, byval newmenu as long) as integer
2.
Sub hiddenmenu ()
Dim hwnd as long
Hwnd = getactivewindow ()
Call setmenu (hwnd, 0)
End sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.