Subject: RE: Lotuscript problem
Brane,
I’m looking at the New code you posted… I can’t comment on the logic… just really the syntax…
I hope this helps…
Dim s As New NotesSession
Dim db As NotesDatabase
Dim ugView As NotesView
Dim rnView As NotesView
Dim ug As NotesDocument
Dim rn As Notesdocument
Dim newDoc As NotesDocument
Dim key As Variant
Set db = s.CurrentDatabase
Set rnView = db.GetView(“ZaMAriaNalogKabel”)
If (rnView Is Nothing) Then
Messagebox "Nisam Pronašao View-ZaMariaNalogKabel"
Exit Sub
End If
’ It looks like you should correctly have rnView set.
Set ugView = db.GetView(“ZaMariaUgovori”)
If (ugView Is Nothing) Then
Messagebox "Nisam Pronašao View-ZaMariaUgovori"
End If
’ It looks like you should correctly have ugView set.
Set ug = ugView.GetLastDocument
’ Is there a reason why you’re using GetLASTDocument here? Typically people use GetFIRSTDocument.
’ Be advised that this has nothing to do with the ORDER of documents in the VIEW. You’re not actually getting the very
’ Last or First document.
’ However at this poing ug should be a document
'While Not (ug Is Nothing)
’ This is still remarked so we’re not actially looping.
key=ug.GetItemValue(“jmbg”)
’ I don’t typically use “GetItemValue” here. I use the short notation and say:
’ key = ug.jmbg(0)
’ If you insist in using GetItemValue then it should probably look like this:
’ key = ug.GetItemValue(“jmbg”)(0)
'Add This so you at least know what’s happening:
if key = “” then
messagebox("Key Not Found")
exit sub
end if
Set rn = rnView.GetDocumentByKey(key)
If Not (rn Is Nothing) Then
Messagebox "JMBG=" & jmbg,,"JMBG "
Else
Messagebox "Nisam pronašao odgovarajući radni nalog",, "Greška"
End If
’ I can’t tell the language but if the doc IS nothing then you should add an “Exit Sub” to stop the code from processing.
Set newDoc = db.CreateDocument
newDoc.form = “ZaMaria”
newDoc.kom = ug.GetItemValue(“organizacija”)(0)
newDoc.adr=ug.getitemvalue(“adresadobavljac”)(0)
’ Again add the Zero’s above or switch to shorthand.
’ newdoc.kom = ug.organizacija(0)
’ newdoc.adr = ug.adresadobavljac(0)
newDoc.jmbg=key
newDoc.ComputeWithForm False,True
Call newDoc.Save(False,False)