user1525825
user1525825

Reputation: 269

Lotusscript NotesDocument values

I am analyzing a module in lotuscript which is fetching a NotesDocument .

Now consider as an example the NotesDocument encapsulates the following data :

docvalue:<html><head> head </head><body>body</body></html>

Now how does the following work?

Dim document As NotesDocument    
Dim data as Variant    
' Assume code to fetch NotesDocument has been done.
' statement to fetch html data.    
data=document.docvalue(0)

I did not find any Lotus documentation where we can fetch value after ":" as a separator(in this case docvalue: as seen in data above). Please let me know how this works or any link to the documentation.

Thanks in advance.

Upvotes: 0

Views: 1064

Answers (2)

Karl-Henry Martinsson
Karl-Henry Martinsson

Reputation: 2795

Knut has the correct answer, if you use Notes 6.x or later (I believe) you can use StrRight().

In addiotion, I would like to point out that the code should be modified slighty. You first declare data as a variant, but then you read just the first string value of the field.

If it is a multi value field (and you want all values back, in an array), declare the variable as variant but read the whole field back. If you only want the first value (or if the field only contains one value), declare data as String and get the first element like you do.

Also, I hightly recommend not to use the extended notation as you do, use the GetItemValue method of the NotesDocument class instead. It is considered best practices, it is forward compatible, and also faster. I also always capitalize the field names exactly as they are in the document, again for performance reasons. It may not make a difference here, but when you are using for example GetView(), the capitalization does matter.

So your code should look something like this:

Dim doc As NotesDocument    
Dim data as String    
Dim html as String
' Assume code to fetch NotesDocument has been done.
' statement to fetch html data.    
data = doc.GetItemValue("DocValue")(0)
html = StrRight(data,":")
Print html

Or, if you have muliple values:

Dim doc As NotesDocument    
Dim dataArray as Variant    
Dim html as String
' Assume code to fetch NotesDocument has been done.
' statement to fetch html data.    
dataArray = doc.GetItemValue("DocValue")
ForAll item in dataArray
    html = StrRight(item,":")
    Print html
End Forall

Upvotes: 1

Knut Herrmann
Knut Herrmann

Reputation: 30960

Use strRight(). It gives you the string right from a search string:

data=strRight(document.docvalue(0), ":")

Upvotes: 3

Related Questions