Bonjour,
Quel est la fonction équivalente au @DbLookUp en LS?
Comment ça ? J'ai les réponses et je n'ai rien payé.Michael DELIQUE a écrit:le site est sympa mais payant...
Accepted Answer from Bozzie4
Date: 11/23/2005 11:16AM PST
Grade: A
Accepted Answer
Yes, but it requires more lines of code - this is an example of a function that would do more or less the same.
function dblookup( db as notesdatabase, viewname as string, key as variant, resultfield as string) as variant
dim view as notesview
dim coll as notesdocumentcollection
Set view = db.getview( viewname )
dim result() as variant
dim count as long
count=0
set coll = view.getalldocumentsbykey( key, true )
redim result(coll.count)
if coll.count = 0 then
result(0)=""
else
set doc = coll.getfirstdocument()
do while not doc is nothing
result(count) = doc.getitemvalue( resultfield )
loop
end if
dblookup=result
end function
cheers,
Tom
Assisted Answer from mbonaci
Date: 11/24/2005 08:04AM PST
Grade: A
Assisted Answer
I wrote it a few months ago and saved it to my Code Library (which you can download, as a template, on OpenNTF - http://www.openntf.org/Projects/pmt.nsf ... %20Library ):
Function dbColumn( db As NotesDatabase, viewName As String, columnNo As Integer, flgUnique As Boolean ) As Variant
'Mb¤, 30.08.2005.
'Works like @DbColumn
On Error Goto ErrHandler
Dim tmpStr As String, strDbPath As String
strDbPath = Strleftback( db.FilePath, "\" ) & "\\" & db.FileName
If flgUnique Then
tmpStr = |@Unique( @DbColumn( "" : "NoCache"; "| & db.Server & |" : "| & strDbPath & |"; "| & viewName & |"; | & columnNo & | ) )|
Else
tmpStr = |@DbColumn( "" : "NoCache"; "| & db.Server & |" : "| & strDbPath & |"; "| & viewName & |"; | & columnNo & | )|
End If
dbColumn = Evaluate( tmpStr )
Exit Function
ErrHandler:
'write your own cuz I use my function
End Function
Comment from mbonaci
Date: 11/24/2005 08:06AM PST
Comment
Oh sorry dblookup, not column.
But you can easely change it...
Hope this helps,
Marko
Comment from Jaziar
Date: 11/28/2005 08:09AM PST
Author Comment
Guys I am going to increase the points on this one, I know very little about LotusScript, but I am pretty sure what I need has to be written in script (maybe Javascript) can you help me how to put the functions in a action or give me a better way of doing the task.
here is what I am trying to do and I am badly in need of help.
on my main view, I have a action button, below is what I am wanting it do to.
I want to do something like a dblookup
test := @DbLookup("":"NoCache";""; "(UserRole)"; @UserName; "UserRole");
test value can be "AA", "Manager", "Employee" depending on who is clicking the button.
if test is equal to anything other than AA - I want to set the field Manager (which is on the opening document) to UManager (this is a value in UserRole view)
if test is AA (this is the hard part) I need for a dialogbox or picklist or something where the user can select a name from a list. This list of names are coming from a value/field names AAManager which is also in the UserRole view. after they select a name then I want to set the value of Manager on the opening form to the selected value.
AAs are assistants where I work and they are assigned mutiple managers to work for, when a AA creates a docuement, the form needs to know which manager the document is being created for, that is why I need the picklist/dialog/something, so the AA can pick the manager
if the manager or a employee creates a document all I need is thier manager, which is UManager to be placed on the form
I am very stuck on this and need as much help as you can give
Comment from Jaziar
Date: 11/28/2005 10:50AM PST
Author Comment
I got this working by using logic from both of the above answers