Manage Learn to apply best practices and optimize your operations.

Get Dynamic Keywords Prompt By A Script Call.

In many cases you have a lot of keywords fields in your ui documents to select
from values stored in other documents, then you make a lookup formula in each
keyword field to draw the
required values.

You may change this way to a smarter appearance and more consistent way by
using action buttons and normal text fields next to them.
The follwing script will make use of a central script call for any keyword
prompt so you do not need for a lookup formulas distributed in your fields.

Make the difinition of the document(s) that containing the keywords in the
global section of your form, then call my dynamic script in each button.

Sirry Hboos

'in global declaration of the form:
'Option Public
'Option Declare
'Use "CommonFunctions" ' contains ImportKeywords
'Dim curItemName$, farItemName$, DialogType% ' used to ImportKeywords for a
multible buttons
'in post open
'Call DefinefarDocuments ' define the source documents for data
'now in each button put your call as follow:
' curItemName$ = "Country"
' farItemName$ = "Country"
' Call ImportKeywords ( fardoc1, curItemName, farItemName, DialogType)
Sub ImportKeywords ( fardoc As notesdocument, curItemName$, farItemName$,
' DialogType discussed here for this sub are 2 only as follow

Const Title = "Keywords"
Const fardocNotFoundMsg$ = "Keyword Source document not found to get the
Const Prompt = "Select the required keyword(s).."
Const NoKeywordsMsg = "No keywords found in the source document"
Const InternalErrMsg$ = "Internal Error - Item Name parameters are not correct"
Dim w As New notesUIworkspace
Dim uidoc As notesUIdocument
Dim doc As notesdocument
Dim farItem As NotesItem, curItem As NotesItem
Dim ChoiceList As Variant, Choice As Variant, DefVal As Variant
Dim Msg$
If fardoc Is Nothing Then
Msg = fardocNotFoundMsg
Goto NotValid
End If
On Error Goto ErrorHandler
Set uidoc = w.currentdocument
Set doc = uidoc.document
Set farItem = fardoc.GetFirstItem ( farItemName )
Set curItem = doc.GetFirstItem ( curItemName )
If farItem Is Nothing Then
Msg = InternalErrMsg
Goto NotValid
If farItem.Text = "" Then
Msg = NoKeywordsMsg
Goto NotValid
End If
End If
If curItem Is Nothing Then
Msg = InternalErrMsg
Goto NotValid
End If
DefVal = curItem.Values
doc.tmp1 = farItem.Values
doc.tmp2 = curItem.Values
ChoiceList = Evaluate({@Unique(@Trim(tmp1 : tmp2))}, doc)
Choice = w.Prompt( DialogType, Title, Prompt, DefVal, ChoiceList )
Call doc.RemoveItem ( "tmp1" )
Call doc.RemoveItem ( "tmp2" )
If Isempty (Choice) Then Exit Sub
Call doc.ReplaceItemValue ( curItemName, Choice )
Call uidoc.Reload
Exit Sub
Msgbox Msg, , Title
Exit Sub
Msgbox "Unexpected error: " & Error & " (" & Err & ")", , Title
Err = 0
Exit Sub
End Sub

Dig Deeper on Domino Resources

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...