Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create New Document

Status
Not open for further replies.

freak11

Programmer
Jun 16, 2006
20
MX
Hi...
here is my thingy... i find this script somewhere in this forum posted by pmonett...

dim session as new notessession
dim db as notesdatabase
dim doc as notesdocument

set db = session.currentdatabase
set doc = db.createdocument
'set various fields here
'
'now set the form to be used
doc.form = "Component Pulp"
'finally, save the document
call doc.save(true,false,true)


it works perfectly... but i want to know if theres is a way to get the values for the field from a view... for example... look in a view in a certain Column, in a certain Row and set
doc.field = row,column,view (specifiin what view and what row and column is the value)

tnx for ur time

 
Well... i got this code working... tnx to Pascal :D
but now... this code is just a test
what i really got to do is this:
the code i have is doing everything in the same database...
but... how it should be is:
the view im using to get doc2 is in Database "x"
and the docs im creating (doc) is gotta be created in database "y" im not sure yet if both databases r gonna be in same server... but i think thats not a problem... am ir right? :)
Code:
Dim doc As NotesDocument
	Dim doc2 As NotesDocument
	Dim docu As NotesDocument
	Dim oldcoc As NotesDocument
	Dim session As New NotesSession
	Dim db As NotesDatabase
	Dim view As NotesView
	Dim entry As NotesViewEntry
	Dim entry2 As NotesViewEntry
	'Dim oldcoc As NotesViewEntry
	Dim vc As NotesViewEntryCollection
	Set db = session.CurrentDatabase
	Set view = db.GetView("Prueba2")
	Set docu = view.GetFirstDocument
	Set vc = view.AllEntries
	Set entry = vc.GetFirstEntry
	Do While Not(docu Is Nothing)
		Set olddoc = docu
		Set docu = view.getNextDocument(olddoc)
		Delete olddoc
		Set doc2 = entry.Document
		doc2.Form = "encuesta2"
		doc2.flag2 =1 'takes it out of the view
		Call doc2.Save (True, False,False)
		Set doc = New NotesDocument(db) 
		doc.Form = "encuestaprueba"
		doc.nombre11 = entry.ColumnValues(0)
		doc.rpe11 = entry.ColumnValues(3)
		doc.departamento11 = entry.ColumnValues(1)
		doc.curso11 = entry.ColumnValues(2)
		doc.puesto11 = entry.ColumnValues(4)
		'doc.fechacurso1 = entry.ColumnValues(1)
		'doc.fechacurso_11 = entry.ColumnValues(2)
		'doc.capacitacion11 = entry.ColumnValues(8)
		doc.flag11 = 0
		doc.subject = " Encuesta"
		Call doc.Save (True, False,False)
		'Call doc.Send(True, entry.ColumnValues(0))
		Set entry2 = entry
		Set entry = vc.GetNextEntry(entry2)
	Loop
 
could this be something like this...
Code:
...
Dim db As NotesDatabase
[b]Dim db2 As NotesDatabase("server","db.nsf")[/b]
...
Do While Not(docu Is Nothing)
        Set olddoc = docu
        Set docu = view.getNextDocument(olddoc)
        Delete olddoc
        Set doc2 = entry.Document
        doc2.Form = "encuesta2"
        doc2.flag2 =1 'takes it out of the view
        Call doc2.Save (True, False,False)
        [b]Set doc = New NotesDocument(db2)[/b]
        doc.Form = "encuestaprueba"
        doc.nombre11 = entry.ColumnValues(0)
        doc.rpe11 = entry.ColumnValues(3)
        doc.departamento11 = entry.ColumnValues(1)
        doc.curso11 = entry.ColumnValues(2)
        doc.puesto11 = entry.ColumnValues(4)
...
 
How do i create a Variable of a NotesDatabase with a certain database:

Could this work?
Dim db2 As NotesDatabase("server","db.nsf")

plz help... im stock in there
 
Code:
Sub Click(Source As Button)
	Dim doc As NotesDocument
	Dim doc2 As NotesDocument
	Dim docu As NotesDocument
	Dim oldcoc As NotesDocument
	Dim session As New NotesSession
	Dim db As NotesDatabase
	[b]Dim db2 As NotesDatabase
	Set db2 = session.GetDatabase("LDCENX05/HMO/CFE", "apps\\sig\\sigsiscap.nsf")[/b]
	Dim view As NotesView
	Dim view2 As NotesView
	
	[b]Set view2 = db2.GetView("V_SIG_CFG_personal_mail")[/b]
	Dim entry As NotesViewEntry
	Dim entry3 As NotesViewEntry
	Dim entry2 As NotesViewEntry
	'Dim oldcoc As NotesViewEntry
	Dim vc As NotesViewEntryCollection
	Set db = session.CurrentDatabase
	Set view = db.GetView("Prueba2")
	Set docu = view.GetFirstDocument
	Set vc = view.AllEntries
	Set entry = vc.GetFirstEntry
	Do While Not(docu Is Nothing)
		[b]Set entry3 = view2.GetEntryByKey(entry.ColumnValues(0))[/b]
		Set olddoc = docu
		Set docu = view.getNextDocument(olddoc)
		Delete olddoc
		Set doc2 = entry.Document
		doc2.Form = "encuesta2"
		doc2.flag2 =1 'takes it out of the view
		Call doc2.Save (True, False,False)
		Set doc = New NotesDocument(db)
		doc.Form = "encuestaprueba"
		doc.nombre11 = entry.ColumnValues(0)
		doc.rpe11 = entry.ColumnValues(3)
		doc.departamento11 = entry.ColumnValues(1)
		doc.curso11 = entry.ColumnValues(2)
		doc.puesto11 = entry.ColumnValues(4)
		[b]doc.atrabajo11 = entry3.ColumnValues(12)[/b]
		doc.flag11 = 0
		doc.subject = " Encuesta"
		Call doc.Save (True, False,False)
		'Call doc.Send(True, entry.ColumnValues(0))
		Set entry2 = entry
		Set entry = vc.GetNextEntry(entry2)
	Loop
End Sub

Here is the code... and when i run it it says "Object Variable Not Set" i bolded eveything i change since the last time it workd..
So all i need is to get avalue for doc.atrabajo11 from a view in a diferent database... i hope u can guys help me
tnx
 
Set entry3 = view2.GetEntryByKey(entry.ColumnValues(0))

theres the problem... but idk what is it
 
ammm... nvm mind... i had the name of the view wrong... so i think its done... tnx for help...
and sorry
ill let u know if anything happen
 
Here is teh code done
it works... BUT...
when i use doc.send(.....)
it actually send the docs... but those docs r not the same doc i saved, those docs r like a copy of the docs... they r not saved in the databases i specified.. theyr saved in the mail databases... i think... im not really sure...
is there a way to send a Link to the dont instead of the doc it self... just like in @MailSend([includedoclink])
but in LotusScript??? plz help... its almost over
Code:
Dim doc As NotesDocument
	Dim doc2 As NotesDocument
	Dim docu1 As NotesDocument
	Dim docu2 As NotesDocument
	Dim session As New NotesSession
	Dim nav As NotesViewNavigator
	Dim db As NotesDatabase
	Dim db2 As NotesDatabase
	Dim view2 As NotesView
	Dim view3 As NotesView
	Dim oldentry As NotesViewEntry
	Dim entry As NotesViewEntry
	Dim entry2 As NotesViewEntry
	Set db = session.CurrentDatabase
	Set db2 = session.GetDatabase("LDCENX05/HMO/CFE", "apps\\sig\\sigformat.nsf")
	Set view2 = db2.GetView("V_SIG_CFG_personal_email")
	Set view3 = db2.GetView("V_CAPA_AC_filtrorac_3")
	Set nav = view3.CreateViewNav()	
	Set entry = nav.GetFirst
	Do While Not(entry Is Nothing)
		Set entry2 = view2.GetEntryByKey(entry.ColumnValues(3))
		Set doc = New NotesDocument(db)
		doc.Form = "encuesta1"
		doc.nombre1 = entry.ColumnValues(3)
		doc.rpe1 = entry2.ColumnValues(2)
		doc.departamento1 = entry2.ColumnValues(4)
		doc.curso1 = entry.ColumnValues(0)
		doc.puesto1 = entry2.ColumnValues(3)
		doc.atrabajo1 = entry2.ColumnValues(12)
		doc.fechacurso = entry.ColumnValues(1)
		doc.fechacurso_1 = entry.ColumnValues(2)
		doc.flag1 = 1
		doc.subject = " Encuesta"
		Call doc.Save (True, False,False)
		[b]Call doc.Send(True, entry.ColumnValues(0)) [/b]
		
		Set doc2 = New NotesDocument(db)
		doc2.Form = "encuesta2"
		doc2.nombre2 = entry.ColumnValues(3)
		doc2.rpe2 = entry2.ColumnValues(2)
		doc2.departamento2 = entry2.ColumnValues(4)
		doc2.puesto2 = entry2.ColumnValues(3)
		doc2.curso2 = entry.ColumnValues(0)
		doc2.atrabajo2 = entry2.ColumnValues(12)
		doc2.fechacurso2 = entry.ColumnValues(1)
		doc2.fechacurso2_1 = entry.ColumnValues(2)
		doc2.Subject = "Encuesta"
		doc2.flag2 = 1
		Call doc2.Save (True, False,False)
		[b]Call doc2.Send(True, entry2.ColumnValues(12))[/b]
		Set oldentry = entry
		Set entry = nav.GetNext(oldentry)
		Delete oldentry
	Loop
 
Hi, I'm back from holidays !

So I've reviewed this thread and, if I'm not mistaken, the current database where doc2 is created is the mail database, right ? It should be, if that is where the document is saved.

Can you create doc2 in the database where it should be saved instead ? Do users have Author rights in that db ?

If that works, then all you need is to create a NotesDocument with a NotesRichTextField in which you create a doclink. When you use the Send method of NotesDocument, you are indeed sending the document. The @Mailsend function does all the steps for you, but in LScript you have to write the code yourself.

That means creating a NotesDocument, creating a NotesRichTextItem in it, creating the doclink in the RTitem based on the doc you wish to link to (be sure that doc is saved before you link to it), and then sending the NotesDocument that contains the RTitem to its recipients.

Without doing the steps I outline above, you won't be sending any doclinks like @Mailsend.

Have fun ! :)

Pascal.
 
Tnx... i figured out that yesterday... is workin now...
tnx for the help..
i think im finishin it for today, im gonna show it up to my boss... lets see what he says... wish me luck
tnx
:-D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top