database:createNote() --note | nil Create a new {{note}} in this database. The created {{note}} is already saved once and has a valid noteid. The returned object should be checked against nil to prevent errors down the line.
local db = domino.getCurrentDatabase()
local note = db:createNote()
if not note then
return
end
-- Use note here database:getAccessLevel() --number Since v254 Check the access level of a {{user}} for the database. The returned number will be between zero and six where zero means no access, and six means manager.
local db = domino.getCurrentDatabase()
local user = request:getUser()
if user then
local level = db:getAccessLevel(user)
print(level) --e.g. 2
end database:getNoteById(noteid: number) --note | nil Open a {{note}} from this database by it's NoteID. The returned object should be checked against nil to prevent errors down the line.
database:getNoteByUnid(unid: string) --note | nil Open a {{note}} from this database by it's UniversalID. The returned object should be checked against nil to prevent errors down the line.
database:getNote(id: number | string) --note | nil Open a {{note}} from this database by it's NoteID or UniversalID. The check is done based on the type that is provided. When a string with a length of 32 is provided, it's opened by its UniversalID. When a number is provided, the {{note}} is opened by it's NoteID. The returned object should be checked against nil to prevent errors down the line.
local id = ... --Add a unid string or noteid number here
local db = domino.getCurrentDatabase()
local note = db:getNote(id)
if not note then
return
end
-- Use note here database:getPath() --string Get the path of this database. The path will use forward slashes regardless of the platform it's used on. The name of the server and the connection port are not included in the string.
local db = domino.getCurrentDatabase()
if db then
local path = db:getPath()
print(path) --e.g. directory/example.nsf
end database:getView(name: string) --view | nil Open a {{view}} from this database by its name. The returned object should be checked against nil to prevent errors down the line.
database:runAgent(name: string, params: table | nil) --string | nil Execute the agent in the current database. The name must be a valid agent name.
The second parameter table will be automatically be converted to a {{note}} in the current database and is automatically cleaned up after the agent has ran (even if it failed).
-- This example assumes an agent named "HeavyWorkAgent" exists in the Workflow's database
local db = domino.getCurrentDatabase()
if db then
local output = db:runAgent("HeavyWorkAgent", {
foo = "bar"
})
print(output) --e.g. "The work was done!"
end