LotusScript Array used to capture entire contents of multivalue field - only getting first entry of multiple values

Posted on 2007-08-06
Last Modified: 2013-12-18
Trying to get the entire contents of the shortname field in the address book - only getting first entry in list.
Please assist.

Function FEmail (docx As NotesDocument) As String
With docx
Dim itemArray As Variant
Dim itemList List
Dim m As Integer

Dim NumFAlias As String 'Declare NumFAlias as type string

itemArray = docx.shortname

For m = 0 To Ubound (itemArray) ' Ubound is a function that returns a number of the highest index in the array itemArray - remember array start with a zero (0) index (if Ubound returns 7 there ' are 8 members in the array)

NumFAlias = itemArray(m) ' Use the value of shortname field
FEmail = Lcase$(NumFAlias & IDOMINIO)
Next m
End With
End Function

Question by:KTTKTT
    LVL 14

    Accepted Solution

    Your program seem to be getting just the last entry.

    NumFAlias = itemArray(m) ' Use the value of shortname field
    FEmail = FEmail & ", " & Lcase$(NumFAlias & IDOMINIO)

    LVL 46

    Assisted Solution

    by:Sjef Bosman
    Hello KTTKTT,

    If you want the entire contents concatenated, try this:

    Function FEmail (docx As NotesDocument) As String
          FEmail= Join(docx.shortname)
    End Function

    LVL 22

    Assisted Solution

    There is nothing syntactically wrong with your code.  Each time the loop executes, a value from the "shortname" field is stored in the "FEmail" variable.  The next time the loop executes, the "FEmail" variable is overwritten with the next value in the field.  At the end of the loop, the "FEmail" variable will hold the last value in the field.

    So, I have to ask:  What are you trying to accomplish with this script?  If we know your intentions, we will be better able to help.

    Author Comment

    cezarF:  used your solution - it worked but now i have to get rid of the commas. How do I do a trim with this solution to remove commas?

    sjef_bosman: thanks for this example as well.

    Bill-Hanson: I appreciate the thorough explanation on how the code was looping - that explained the problem.   Just simply grabbing the shortnames to export to .xls.
    LVL 22

    Assisted Solution

    Sjef had the easiest solution:

    FEmail= Join(docx.shortname)

    The Join function does all the looping for you and can delimit the text using any character that you wish.  The default is a space.
    LVL 14

    Expert Comment

    @Kitkit: I Agree sjef and Bill-Hanson. It would have been easier if you used Join.  To answer your question, just change the ", " with " " or any delimiter you want.  


    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
    For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now