Help with Lotus Script in a View

All,

I have a button on a form that works, which allows me to make a folder in a specific location using a field “Directory” as the name of the new folder. I now need to move this button to a view.

I added in some more code to the one that is working trying to get it to work in a view, but so far I haven’t had success.

I have the following code (see bottom) which is giving me a Type Mismatch. I have turned on the debugger but it only tells me the same Type Mismatch. I have viewed other code trying to see what I might be missing or what I might try.

I think the mismatch occurs with the valor statement, but do not know how to fix/change this to determine if that is true.

Sub Click(Source As Button)

Dim session As New NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument

Dim valor As Variant



Set session = New NotesSession	

Set db = session.CurrentDatabase

Set view = db.GetView( "Admin Assis" )

Set doc = view.GetFirstDocument



valor = doc.GetItemValue( "Directory" ) 



Mkdir "C:\Documents and Settings\terico\My Documents\Test\" + valor

End Sub

Any help is greatly appreciated.

TIA

Teri

Subject: Help with Lotus Script in a View

Teri, Try this:

valor = doc.directory()

Subject: RE: Help with Lotus Script in a View

Timothy,

Thanks for the response. I tried what you posted and it gave me this error: Wrong number of array subscripts.

So I tried this valor = doc.directory(0) and it gave me this error: Path/file access error.

Any other suggestion?

Teri

Subject: RE: Help with Lotus Script in a View

you have valor as a variant…Dim it as a String.

Subject: RE: Help with Lotus Script in a View

OK, tried that. Still getting the same errors. if () are empty then wrong number of array subscripts, if (0) holds the 0 then Path/file access error.

Any other ideas?

Thanks Teri

Subject: RE: Help with Lotus Script in a View

The expression doc.Directory returns an array. I assume it’s a single-valued field, but the value you get back is still an array containing one element, with index 0. So you have two choices: you can store the entire value into a Variant:

valor = doc.Directory ’ or doc.GetItemValue(“Directory”)

Mkdir "C:\Documents and Settings\terico\My Documents\Test" + valor(0)

Since it is assigned an array value, valor would have th be declared as Variant in this case.

Or, you can store just the first element:

valor = doc.Directory(0) ’ or doc.GetItemValue(“Directory”)(0)

Mkdir "C:\Documents and Settings\terico\My Documents\Test" + valor

In this case, since valor will just contain a string, you can declare it as a string, or you can declare it as variant. It should not matter.

The “Path/file access error” is occurring on your mkdir line. This is because, for reasons of access or because you have a messed-up directory path, it is unable to create the directory. It does not have anything to do with whether you declared valor as variant or string. You concatenate a string with something, the result is a string, regardless of the type of the something. The question that you need an answer to, is what does that string contain?

You can find this out using the LotusScript debugger. You say you turned it on but it sounds like nothing different happened. This is because you must close and reopen the document so that the debugger will have a chance to “grab” the LotusScript code on your form and start debugging it.

Also, you can design your code so that it always tells you what line an error occurred on. Details in Debugging Domino Applications part 1 and part 2.

Subject: RE: Help with Lotus Script in a View

Andre,

Thank you for your insight. Once I closed the database, turned on the debugger, then opened the database and view, I was able to see where the error was occuring. I have sinced printed out the two tutorials on debugging and will read them.

That said please see the code at the bottom for what I am using now. I rem’ed out the Mkdir and put in a messagebox to see what value was being grabbed. As you so nicely put it I have a messed-up directory path. I found that valor is returning nothing/empty/zilch. So I am not capturing the information from single-value field with this code.

Any help with this would be greatly appreciated. I will continue to plug along on my own as well.

Dim session As New NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument

Dim valor As Variant



Set session = New NotesSession	

Set db = session.CurrentDatabase

Set view = db.GetView( "Admin Assis" )

Set doc = view.GetFirstDocument



valor = doc.GetItemValue("Directory")



Messagebox valor(0), MB_OK, "Error"



'Mkdir "C:\Documents and Settings\terico\My Documents\Test\"  + valor(0)

Thanks and TIA

Teri

Subject: RE: Help with Lotus Script in a View

Since you say this code works from a document but not from the view, it sounds like the field Directory is only available while the document is open. It is perhaps a “Computed for display” field, which is not stored in the document, so from a view it is not available. Use the document properties dialog from a view to see what item values are actually stored in the document (2nd tab). Make sure you’re looking at the right document (the first one in the view “Admin Assis”).

Subject: RE: Help with Lotus Script in a View

You are either genuis, mind reader, or been doing this way to long to know people’s habits.

In this case, once I scrolled up to insure I was looking at the first document in the view (thought I was) I noticed that the value was empty.

Now I will try to find the code to change it from GetFirstDocument to Get the selected Document.

Thanks much

Teri

Subject: Psychic Andre strikes again!

Subject: RE: Help with Lotus Script in a View

Try this:

dim tempstring as string

tempstring = "C:\Documents and Settings\terico\My Documents\Test" + Cstr(valor)

Mkdir tempString

OR:

Mkdir "C:\Documents and Settings\terico\My Documents\Test" + cstr(valor)

Shawn

Subject: RE: Help with Lotus Script in a View

Shawn,

Thanks for the suggestion. As I wrote Andre, I have found that I am not capturing the information from the field Directory, which is giving me the path error.

I tried to place your snippet in and received a Type MisMatch error. I changed String to Variant and still received MisMatch.

I am now pursuing Andre’s suggestion and so I am trying to determine why I am not capturing the information within the Directory field. This is a plain text, so not sure why I don’t have a handle on it, so any help in that direction would be most appreciated. I will keep on trying to get this to work.

Thanks

Teri

Subject: RE: Help with Lotus Script in a View

how is hte directory field populated? Is it a computed field is it navigated to and stored?

Shawn