LotusScript to export to excel

There is a form with a submit button. I can set out any criteria and if i click on the submit button, the page will go to a view with the search results. I have this “Export to Excel” link which will initiate the export agent written in LotusScript and the data in the page is exported to an excel sheet. The prob comes when a new field which is a text list needs to be introduced in the export sheet. Only the first value in the field gets exported. Ineed to export the whole set of values to the excel sheet.

I used the following code:

If (doctemp.HasItem(“CCTSector”) And doctemp.CCTSector(0) <> “”) Then

	supportteam = doctemp.CCTSector(0)

Else

	supportteam = ""

End If

Here CCTSector is the list field. And support team is the variable that will be exported to excel.

Thanks in advance!!

Subject: LotusScript to export to excel.

Hello, to get all the values you can use dim itCCTSector as NotesItem

set itCCTSector = doc.getFirstItem(“CCTSector”)

supportTeam = itCCTSector.text

or you can call Join(doctemp.CCTSector, “”).

Hopefully this helps…

Jan

Subject: RE: LotusScript to export to excel.

Jan, its not working i tried…

If (doctemp.HasItem(“CCTSector”) And doctemp.CCTSector(0) <> “”) Then

	Dim itCCTSector As NotesItem

	Set itCCTSector = doc.getFirstItem("CCTSector")

	supportTeam = itCCTSector.text

Else

	supportteam =  " Evaluate"

End If

And when i click on the export to excel link, iam gtting “Evaluate” in the column “Support Team” for all the rows…

Subject: RE: LotusScript to export to excel.

Thanks a lotttttttttttt, Jan and Harkpabst.

Its working fine now

:):):):):slight_smile:

Subject: LotusScript to export to excel.

In this line

supportteam = doctemp.CCTSector(0)

you explicitly tell LotusScript to only use the element at index 0 of the array that is used to access the values in a Notes item. If you omit “0”, a variant containing an array of all values is returned.

If and how you have to further process this array depends on what else your code does.

Subject: RE: LotusScript to export to excel.

Harkpabst, u mentioned:" In this line

supportteam = doctemp.CCTSector(0),

If you omit “0”, a variant containing an array of all values is returned.

"

What did u mean by omit “0”? will the new code be as follows?

supportteam = doctemp.CCTSector

or

supportteam = doctemp.CCTSector()

In either case, i am not still getting the values while exporting.

Subject: RE: LotusScript to export to excel.

Sorry for not being more specific about it. As you found out by now, you have to use this syntax

supportteam = doctemp.CCTSector

Anyhow, great you could resolve it. The thing is, that for LotusScript, each item in a note is an array, be it multi-value or not. That’s why you need to add (0) most of the time (if all you want is the first element in that array), but not always.