running mail doc, server link not working properly - lotus-notes

Problem :
Using Agent run and send mail give a different link
Mail Contain a link which is not include database
I set it send to a yahoo mail
Sub Initialize()
Print"Agent:First Reminder for LateIn Reason started running at " & DateValue(Now()) & "," + TimeValue(Now())
Dim ss As New NotesSession
Dim db As NotesDatabase
Dim LateInVw As NotesView
Dim LateInDocs As NotesViewEntryCollection
Dim LateEntry As NotesViewEntry
Dim LateDoc As NotesDocument
Dim StaffVw As NotesView, StaffDoc As NotesDocument
Dim MailDoc As NotesDocument
Dim rtBody As NotesRichTextItem
Dim sysdoc As NotesDocument, sysVw As NotesView
Dim AttVw As NotesView, Attdoc As NotesDocument
Set db=ss.Currentdatabase
Set sysVw=db.getview("($System Settings)")
Set sysdoc=sysvw.getfirstdocument
If sysdoc Is Nothing Then Exit Sub
Set LateInVw=db.getview("(Testing Late-In Time Records)")
Set StaffVw=db.getview("($Active Staff by ID)")
Set AttVw = db.Getview("($Effective Attendance Setting By ID)")
tdy=Datevalue(Now)
'get all time records for today
Set LateInDocs=LateInVw.Allentries
Set lateEntry=LateInDocs.getfirstentry
Do While Not LateEntry Is Nothing
Set LateDoc=LateEntry.Document
Set Attdoc=Attvw.Getdocumentbykey(LateDoc.TStaffID(0), True)
If Attdoc.LateAtt(0)="Yes" Then
If LateDoc.LateReason(0)="" Then
If Not ApprovedLateIn(LateDoc, LateDoc.TAmend(0), False) Then
'get staff mail
Set staffDoc=StaffVw.Getdocumentbykey(LateDoc.TStaffID(0), True)
If Not staffdoc Is Nothing Then
'send email with link to main menu
If email$<>staffDoc.email(0) Then
' email$=staffDoc.email(0)
email$="chee111385#gmail.com"
Set Maildoc=New NotesDocument(db)
Set maildoc=db.Createdocument()
maildoc.Form="First Reminder Notification"
maildoc.Subject="Smartcard Attendance System: Late-In Notification for " +Format$(LateDoc.TDate(0),"dd/mm/yyyy")
Maildoc.StaffName=staffDoc.StaffName(0)
maildoc.Sendto="chee111385#gmail.com"
' maildoc.NotifyDate=LateDoc.Tdate(0)
maildoc.NotifyTime=Timevalue(LateDoc.TAmend(0))
maildoc.NotesServer=sysdoc.ServerPath(0)
maildoc.NotesDBPath=sysdoc.DBPath(0)
maildoc.send(True)
End If
End If
End If 'check against unimas's jadual kedatangan
End If 'check for late in reason
End If 'check late-in on/off in attendance settings
Set LateEntry=LateInDocs.Getnextentry(LateEntry)
Loop
End Sub
I will attach my image file and coding here
from this 2 image you can see that, actually i want to put as a
notes://Mulu/SmartCard Attedancce/sas-server.nsf/Scais Main?OpenFrameset
but result of the mail send out is
notes:////Scais Main?OpenFrameset
which is no server and database. I am not sure what part of my coding is wrong
Another attachment will be the form i use as mail.form

First of all: Sending an external mail with a custom form like you do it is not the best Idea, as the target system might not be able to render everything accordingly.
That said, I would first create a document that contains all data and then RENDER it to a maildoc. code would look like this:
Dim Templatedoc as NotesDocument
Dim body as NotesRichtextItem
Set Templatedoc=New NotesDocument(db)
Set Templatedoc=db.Createdocument()
Templatedoc.Form="First Reminder Notification"
Templatedoc.StaffName=staffDoc.StaffName(0)
' maildoc.NotifyDate=LateDoc.Tdate(0)
Templatedoc.NotifyTime=Timevalue(LateDoc.TAmend(0))
Templatedoc.NotesServer=sysdoc.ServerPath(0)
Templatedoc.NotesDBPath=sysdoc.DBPath(0)
Set maildoc=New NotesDocument(db)
maildoc.Form = "Memo"
maildoc.Subject="Smartcard Attendance System: Late-In Notification for " +Format$(LateDoc.TDate(0),"dd/mm/yyyy")
maildoc.Sendto="chee111385#gmail.com"
Set body = New NotesRichtextItem( maildoc, "Body" )
Call Templatedoc.RenderToRTItem( body )
maildoc.send(True)
Second: You set two fields (NotesServer and NotesDBPath) to compute your Link. But your link in reality is computed from environment- variables, and these are not set on the server.
Change your Link- Computation- Formula to:
srv := NotesServer;
pth := NotesDBPath;
That should do the trick for the link.

Related

Copy document is saved but original not changes status using lotusscript

I have two document which is original and copy document. When I save copy, original will changes status too.
Follow up by my other question Save copy document and change status field for copy document and original document using lotusscript button. Below are my code.
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim activeDoc As NotesDocument
Dim view As NotesView
Dim keys(1) As String
'// Set database and doc
Set db = session.CurrentDatabase
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
keys(0) = doc.PTagNo(0)
keys(1) = "Lock"
Set view = db.GetView("Computer")
vpswd = Inputbox$("Pls input code to save :")
If vpswd = "o" Then
Set activeDoc= view.GetDocumentByKey(keys, True)
If Not activeDoc Is Nothing Then
If activeDoc.PStatus(0) = "Lock" Then
activeDoc.DocumetId = doc.UniversalID
Call activeDoc.ReplaceItemValue("PStatus", "Inactive")
Call activeDoc.Save(True, False)
End If
End If
Call uidoc.FieldSetText("PStatus" , "Active")
Call uidoc.FieldSetText("SaveOptions" , "1")
Call uidoc.Save
Call uidoc.Close
Else
Msgbox "Wrong Code"
Exit Sub
End If
End Sub
I already set variable and successfull saved. When I saved, Copy document is saved and change status to Active, but for Current document which currently with "Lock" status, did not change to "Inactive" status. Can anyone help me? Is there any error that I have made inside coding? Your help really appreciate. Thanks!
I've solved this question. For my problem, I do not set TagNo as my first column. So I need to created new view with two column which is TagNo and Status. Set both column as ascending.

Can't get to any info from Lotus Notes using VBA

Thanks in advance for any help!
I'm ultimately trying to pull information from specific emails based on subject line. Working up to the problem the below code was a test to pull up a subject line. However it runs through 132 documents without a single subject identified as anything other than blank. Using this same Initialize and GetDatabase method I successfully sent emails through Lotus Notes, so I don't think I'm after the wrong docs somehow. Below code written in VBA through Excel have Lotus Notes 8.5
Anyone see a reason why I would get nothing but blanks going through all of the docs in the Notes Database?
Sub LotusGetView()
Dim Nsess As New NotesSession
Dim Ndb As NotesDatabase
Dim Ndocs As NotesDocumentCollection
Dim Ndoc As NotesDocument, docNext As NotesDocument
Dim c As Long
Dim memSubj As Variant
Nsess.Initialize
Set Ndb = Nsess.GetDatabase("", "names.nsf")
Set Ndocs = Ndb.AllDocuments
c = 1
Set Ndoc = Ndocs.GetFirstDocument
Do Until Ndoc Is Nothing Or c = 1000
Set docNext = Ndocs.GetNextDocument(Ndoc)
memSubj = Ndoc.GetItemValue("Subject")(0)
If memSubj <> "" Then
MsgBox memSubj
End If
Call Ndoc.Remove(True)
Set Ndoc = docNext
c = c + 1
Loop
MsgBox c
End Sub
Your problem is this line:
Set Ndb = Nsess.GetDatabase("", "names.nsf")
You are opening names.nsf. That is the user's personal address book database. It is not the user's mail database. Your previous work to send mail worked because you don't need to access a mail database to send mail. You can send mail from anywhere. In order to read mail, you have to open the mail database.
The OpenMailDatabase method of the NotesDbDirectory class provides an easy way for you to find and open the current user's mail database.

No "Script Area" in Lotus Notes Agent editor

I need the functionality described here: Determining which folder contains a document in Lotus Notes without using the LotusScript FolderReferences property
It says: "And the following code in the Script Area". But there's no script area. There's a tree containing "Document Selection", "(Options)", "Declarations", "Initialize", and , "Terminate".
You can enter that code into the body of the Initialize method. Make sure to keep the code that automatically appears when you select Initialize and just enter the code in the middle
Sub Initialize
Dim session As New notessession
Dim db As notesdatabase
Dim doc As notesdocument
Dim doc2 As notesdocument
Dim view As notesview
Dim noteid1 As String
Dim noteid2 As String
Dim item As notesitem
Dim collection As notesdocumentcollection
Set db=session.CurrentDatabase
Set collection=db.UnprocessedDocuments
Set doc=collection.getfirstdocument
noteid1=doc.NoteID
Forall v In db.Views
If v.isfolder Then
Set doc2=v.GetFirstDocument
While Not doc2 Is Nothing
noteid2=doc2.NoteID
If noteid1=noteid2 Then
Messagebox v.name
End If
Set doc2=v.getnextdocument(doc2)
Wend
End If
End Forall
End Sub

Document command is not available whend using uidoc.copy

I got an error 'Document command is not available' when the program hits the uidoc.Copy line. I have researched this error message. But all I get is only if it has anything to do with Edit Mode and I am not using that at all here.
Sub Click(Source As Button)
' ===========================================================
' Get common username, mail server, and mailfile information
to be used on ComposeDocument method
Dim session As New NotesSession
Dim reg As New NotesRegistration
Dim user As String
reg.RegistrationServer = "Test"
user = session.CommonUserName
Call reg.GetUserInfo(user, _
mailserver$, _
mailfile$)
' ======================================================================
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
Call uidoc.GotoField("QSContactEMail")
Call uidoc.SelectAll
Call uidoc.Copy
Set uidoc = workspace.ComposeDocument _
(mailserver$, mailfile$, "Memo")
Call uidoc.GotoField("Subject")
Call uidoc.Paste
End Sub
You don't need to use copy and paste to transfer values from one document to another. You can directly assign those values using document objects.
There are several methods to do this- here is one that is similar to yours. Replace everything below the second line with this:
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument, newuidoc as NotesUIDocument
Set uidoc = workspace.CurrentDocument
Set newuidoc = workspace.ComposeDocument _
(mailserver$, mailfile$, "Memo")
Call newuidoc.FieldSetText("Subject", uidoc.FieldGetText("QSContactEMail"))
End Sub
Check to see if you have a field called $KeepPrivate set to "1". It will prevent copying.
The error can also happen if nothing is selected. Try STOP just before the line and make sure it is highlighted.
There are also other conditions listed here:
http://www-01.ibm.com/support/docview.wss?uid=swg21094450

Filter Process script Library

I have a form called Approver in "Approver" db.
The form has two editable text fields: Office and Group. It also has a dialog list field superior1.
The superior1 dialog list field should show the staff details filtered based on office & group:
if office = TSP & group = HR from the approver form, then shud filter the staffs based on these fields group" & "office" with the "Staff info" view of another database "TSP_Staff" and show in superior1.
But it is not getting filtered for me. :(
I am new to this tech, so I am confused and have no one to help me in this. This is the script I used:
for the superior1 field:
Sub Entering(Source As Field)
Dim s As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim uidoc As NotesUIDocument
Dim doc As Notesdocument
Dim work As New NotesUIWorkspace
Dim workspace As New NotesUIWorkspace
Dim sname As String
Dim consr As String
Dim cview As notesview
Set db = s.CurrentDatabase
Set uidoc = work.CurrentDocument
Set uidocs = workspace.currentdocument
Set cview = db.getview("(Application)")
'etype = uidoc.FieldGetText("Office")
'ftype = uidoc.FieldGetText("Group")
etype = "TSP"
ftype = "TSP1-G"
If(etype <> "" And ftype <> "") Then
Call filter
End If
Set view = db.getview("(x_search_staff)")
Set doc = view.GetDocumentByKey (uidoc.fieldgettext("Superior1"),True)
If doc Is Nothing Then
Msgbox "There is no previous transaction please select new trasaction.", 16, "Information"
Call uidoc.FieldClear("Superior1")
Call uidoc.gotofield ("Group")
Call uidoc.gotofield ("Office")
continue = False
Exit Sub
End If
Call uidoc.Refresh
End Sub
from the script library ...
Sub filter
Dim s As New notessession
Dim w As New notesuiworkspace
Dim uidoc As notesuidocument
Dim doc As notesdocument, newdoc As notesdocument, d As notesdocument, dd As notesdocument
Dim doc1 As NotesDocument, newdoc1 As NotesDocument
Dim dc As notesdocumentcollection
Dim bc As notesdocumentcollection
Dim view As notesview, v As notesview
Dim db As notesdatabase
Dim nextdoc As NotesDocument
Dim cview As notesview
Dim cnview As NotesView
Dim get_db As New notesdatabase(gsserver2, gspath2 & "Master\TSP_Staff.nsf")
Set db = s.currentdatabase
Set view = get_db.getview("(Staff Info)")
Set cview = db.getview("(x_search_staff)")
Set cnview = db.getview("(x_superior)")
Set uidoc=w.CurrentDocument
'To delet searched previous datas from form2 ----------------------------------------
Print "Please wait ..."
key = "Approver2"
Set v = db.getview("(x_delete_2)")
Set dc = v.GetAlldocumentsByKey(key,True)
'Set bc = v.GetAlldocumentsByKey(key,True)
'Call bc.RemoveAll(True)
Call dc.RemoveAll(True)
Call cview.Refresh
Call view.Refresh
Call cnview.Refresh
Call v.Refresh
'To start searching process based on Superior1 --------------------------------------
'f1= uidoc.FieldGetText("Office")
f1= uidoc.FieldGetText("Group")
'f1 = "TSP1-G"
Set dc = view.getalldocumentsbykey(f1, True)
'Set bc = view.getalldocumentsbykey(f2, True)
For b =1 To dc.count
Set doc = dc.getnthdocument(b)
Set newdoc = doc.copytodatabase(db)
'For c =1 To bc.count
'Set doc1 = bc.getnthdocument(b)
'Set newdoc1 = doc.copytodatabase(db)
If doc.form(0) = "Approver" Then
'If doc1.form(0) = "Approver" Then
newdoc.form = "Approver2"
'newdoc1.form = "Approver2"
'End If
End If
newdoc.save True, True
' Next
'newdoc.save True, True
'Next
Call w.viewrefresh
Call cview.Refresh
Call v.Refresh
Call cnview.Refresh
Call view.Refresh
Print "Process Completed....."
End Sub
if u got another way for this requirement temme in stepwise wat to do... or else... chk out ma script for errors... hope u help me :( today due date for this task...
I'm not sure how smart it is to filter the documents shown in a view by deleting documents from a database :)
My suggestion is to first post the code properly. This is simply unreadable.
How to display only subset of documents in your dialog list?
Create a hidden field on your form (you'll fill it with values you want displayed in the list using your code).
And then, on your dialog list field properties, second tab, set choices option to be "Use formula for choices" and set it to be the hidden field name.
Ask if you need more help...
Your code is very hard to follow, but if I understand your intention and parts of the filter function (does it even compile?) you could replace all of the code with this #dblookup-based formula in "use formula for choices" section of superior1 properties:
#dblookup("":"ReCache";"ServerName":"foo\Master\TSP_Staff.nsf";"(Staff Info)";Group;NameOfInterestingField);
You might want to add a #sort and/or #unique around it if the view contain duplicate values, and you might want to add the keyword [FAILSILENT] if some groups should result in an empty list.
An even simpler method could be to configure superior1 to use view dialog for choices.

Resources