开发者

Button Event Field Setting Issue - Lotus Script

开发者 https://www.devze.com 2023-02-15 18:35 出处:网络
I have a button in a form that on brings a picklist of a view\'s documents... My issue is am not able to set the selected document from the picklist into a field \"Superior1\".. plz help me.. followin

I have a button in a form that on brings a picklist of a view's documents... My issue is am not able to set the selected document from the picklist into a field "Superior1".. plz help me.. following is the click event script...

Sub Click(Source As Button)
    Dim session开发者_StackOverflow社区 As New notessession
    Dim view As NotesView 
    Dim view1  As notesview
    Dim doc As notesdocument
    Dim db As Notesdatabase
    Dim Overdb As notesdatabase
    Dim og As String
    Dim Sup As String

Set db=session.CurrentDatabase 
Set Overdb=session.GetDatabase(gsserver, "Master\\ASEAN_Staff.nsf")

Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim picklist As Variant

Set uidoc = workspace.CurrentDocument

og = uidoc.FieldGetText("OfficeGroup_Key")

picklist = workspace.PickListStrings( PICKLIST_CUSTOM,_
False,_
gsserver,_
"Master\\ASEAN_Staff.nsf",_
"x_asean_superior1",_
"Select Name",_
"Choose",_
1,_
og ) 


If Isempty(picklist) Then
    Exit Sub            
Else

    Set view = Overdb.GetView("x_asean_Superior1") 
    Set doc = view.GetdocumentByKey(picklist, False) 

    Sup=doc.ColumnValues(1)

    Call uidoc.FieldSetText("Superior1", Sup)


End If

End Sub

Plz correct me if I am wrong anywhr... On selecting a document from the picklist.. the 1st document gets set into the field "Superior1"... wateva i selected is not getting set in the field...


picklist when returned from PickListStrings is an array of strings. To use its value in GetDocumentByKey use picklist(0) to get the first entry.


When you're using last PickListStrings parameter to restrict documents in a pick list dialog to a category, you never specify 1 as the second to last param, since you don't even see the category (which is the first column) in a dialog.
Instead, to get first visible column use 2.

Also, when using GetdocumentByKey for this purpose, set second parameter to True (you want exact match document, not fuzzy search).

One thing I don't understand, if you're just trying to

set the selected document from the picklist into a field "Superior1"

why don't you simply transfer the value directly from PickListStrings. Just specify the column (visible in dialog) number in the PickListStrings, like this:

...
picklist = workspace.PickListStrings( PICKLIST_CUSTOM,_
False,_
gsserver,_
"Master\\ASEAN_Staff.nsf",_
"x_asean_superior1",_
"Select Name",_
"Choose",_
2,_
og ) 

Call uidoc.FieldSetText("Superior1", picklist(0))

I don't understand why are you doing lookup to get the same document, when you can already get any of its (view column) values using PickListStrings?


One small addition to mbonaci's answer - Note that if the user presses "Cancel" the dialog returns an EMPTY variant. In this case trying to access picklist(0) would result in an error. To account for this, check if IsEmpty(picklist) and if True, do what's appropriate (Exit Sub, etc.).

0

精彩评论

暂无评论...
验证码 换一张
取 消