LotusScript

HiHow difficult is it to convert this formula to LotusScript?

@If(IENEventDate > @Today ; @Command([Compose]; “” ; “CFRF”) & @Command([FileSave]) ; @MailSend(“Colleen Brownhill” ; “” ; “” ; “Please complete Client Feedback Report” ; “” ; “” ; [IncludeDoclink]);“”; “”);

Thanks Coll

Subject: LotusScript

Not too difficult :wink:

HTH - Rufus.

Subject: RE: LotusScript

Thanks…any tips, i am being cheeky ( i know) just got a block and had a long week.C

Subject: RE: LotusScript

A few random snippets of code that might help

If doc.IENEventDate(0) > Today then…

Call workspace.ComposeDocument( “”, “”, “CFRF”)

or

set doc = db.CreateDocument

doc.Form = “CFRF”

call doc.save(true,true)

Call workspace.EditDocument(True, doc)

Set mailDoc = db.CreateDocument

mailDoc.Form=“Memo”

mailDoc.sendTo=“Colleen Brownhill”

mailDoc.subject=…

set rtItem = New NotesRichTextItem(mailDoc,“Body”)

Call rtItem.appendDocLink(doc,“Click here”)

call mailDoc.send(false)

HTH - Rufus.

Subject: RE: LotusScript

Thanks so much for your help, I think I am still missing the plot a bit…have included my code so far, please let me know if I am doing something wrong with my view.

Sub Initialize

Dim session As New NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument

Dim workspace As NotesUIWorkspace

Set db = session.CurrentDatabase

Set view = db.GetView( "(CheckMeetingDate)" )

Set doc = view.GetFirstDocument

If doc.IENEventDate(0) > Today Then

	Call workspace.ComposeDocument( "", "", "CFRF")

	Set doc = db.CreateDocument

	doc.Form = "CFRF"

	Call doc.save(True,True)

	Call workspace.EditDocument(True, doc)

	

	Set mailDoc = db.CreateDocument

	mailDoc.Form="Memo"

	mailDoc.sendTo="Colleen Brownhill"

	

	Set rtItem = New NotesRichTextItem(mailDoc,"Body")

	Call rtItem.appendDocLink(doc,"Click here")

	Call mailDoc.send(False)

End If		

End Sub

Thanks…Coll

Subject: RE: LotusScript

You do just want someone to write the code for you then :wink:

You are using doc for the first document in the view AND doc for the document you are creating - I’d suggest putting them in different variables!

Why are you using ComposeDocument AND CreateDocument - I was suggesting you could use one OR the other, not both!

That should get you a bit further, if you hit any more problems then post your code again with details of exactly what the problem is, and where in the code the problem is being caused.

Rufus.

Subject: RE: LotusScript

Hi I feel bad…really get stuck with script.This is the code so far, it does create a cfrf doc but does not close. also, i will need to pull some more fields through from the selected meeting as it needs to save correctly in the view…will figure that one out.

Sub Initialize

Dim session As New NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument

Dim workspace As New NotesUIWorkspace

Set db = session.CurrentDatabase

Set view = db.GetView( "(CheckMeetingDate)" )

Set Vdoc = view.GetFirstDocument

If Vdoc.IENEventDate(0) < Today Then

	Set doc = db.CreateDocument

	doc.Form = "CFRF"

	Call doc.save(True,True)

	Call workspace.EditDocument(True, doc)

	

	Set mailDoc = db.CreateDocument

	mailDoc.Form="Memo"

	mailDoc.sendTo="Colleen Brownhill"

	

	Set rtItem = New NotesRichTextItem(mailDoc,"Body")

	Call rtItem.appendDocLink(doc,"Click here")

	Call mailDoc.send(False)

End If		

End Sub

Thanks…you have made my week.

C

Subject: RE: LotusScript

If you don’t need the CFRF form displayed then simply don’t open it, keep everything in the backend i.e.

delete the following line:

Call workspace.EditDocument(True, doc)

As for pulling fields across from the “selected doc” then

Dim selectedDC As NotesDocumentCollection

Dim selectedDoc As NotesDocument

Set selectedDC = db.UnprocessedDocuments

if selectedDC.count <> 1 then

msgbox “Please select exactly one document”

exit sub

end if

set selectedDoc = selectedDC.GetFirstDocument

…

doc.field1 = selectedDoc.parentfield1

doc.anotherfield = selectedDoc.afield

etc.

call doc.save(true,true)

unless you were referring to vDoc as the selected document in the view in which case you can ignore all of the first bit.

HTH - Rufus.

Subject: RE: LotusScript

Hi RufusMany thanks for all the help. I am still a bit stuck with this code…I want to run the agent in the background so will using a selected doc work? Also, what should happen is that when the CFRF is saved and it has “inhertited” the existing company name from the original doc that holds the meeting date, it will save correctly in the view. At the moment, obviously it is creating a blank CFRF.

Thanks again!

C

Subject: LotusScript

Hi,

it is not very difficult at all.

Best regards
Mario Varchmin