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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forms

Status
Not open for further replies.

scott1es

IS-IT--Management
Jan 31, 2002
8
US
I am trying to create a form that allows users to sign up for training and when they submit it it goes to their (via e-mail) Supervisor who approves it and then it will forward on to the Training Coordinator. ANy suggestions or links to help me with this would be greatly appreciated. Thanks.
 
We have a leave accounting Notes database that does something similar. Here is the PostOpen event that gathers the information regarding the manager to send to:
Code:
Sub Postopen(Source As Notesuidocument)
Dim db As NotesDatabase	
Dim doc As NotesDocument
Dim uidoc As NotesUIDocument
Dim workspace As New NotesUIWorkspace
Dim view As NotesView
Dim session As New NotesSession
Dim UserName As String
Dim DivisionName As String
Dim Rank As Double
Dim keys( 1 To 2 ) As String

Set uidoc = workspace.CurrentDocument    	
If uidoc.EditMode = False Then Exit Sub
Set db = New NotesDatabase( "SERVERNAME", "names.nsf" )
Set view = db.GetView( "Peoples" )
keys( 1 ) = uidoc.FieldGetText( "dspDivision" )
keys( 2 ) = uidoc.FieldGetText( "UserID" )
UserName = uidoc.FieldGetText( "UserID" )
DivisionName = uidoc.FieldGetText( "dspDivision" )
Set doc = view.GetDocumentByKey(keys)
Rank=Cdbl(doc.PersonalID(0))
If Not Isnumeric(doc.EmployeeID(0)) Then 
Messagebox "Employee ID is not valid. Contact Human Resources."
Call uidoc.Close
Exit Sub
End If
ManagerName = Trim$(Strleft(Mid$(doc.Manager( 0 ),4),"/"))
If ManagerName = ""  Then 
Messagebox "Manager Name is not valid. Contact Human Resources."
Call uidoc.Close
Exit Sub
End If
Call uidoc.FieldSetText( "Department", doc.Department( 0 ) )
Call uidoc.FieldSetText( "SocialSecurity", doc.EmployeeID( 0 ) )
Call uidoc.FieldSetText( "Manager",ManagerName )
Call uidoc.FieldSetText( "Rank", Cstr(Rank)) 
Call uidoc.FieldSetText( "RequestDate",Format(Now(),"m/d/yyyy hh:mm AM/PM" ))
Call uidoc.FieldSetText( "SendTo",ManagerName )
Call uidoc.Refresh
End Sub

Then in the 'SUBMIT REQUEST' button the following formula language determines who to send it to and then sends:

Code:
	@If(Department = "-- Choose Appropriate --"; @Prompt([OK];"Missing Data";"You must specify your department name");@Success);
@If(Department = "-- Choose Appropriate --";@Return("");@Success);
FIELD EndDate:=StartDate;
@If (EndDate="";@Prompt([OK];"Missing Data";"You must enter valid dates");@Success) ;
@If (EndDate="";@Return("");@Success);
FIELD ApprovalLevels:=@DbLookup("";"MetroNT4":"Leave.NSF";"LeaveDescription"; 	ReqType;3);

@If (TotalHours="";@Prompt([OK];"Missing Data";"You must enter valid hours");@Success) ;
@If (TotalHours="";@Return("");@Success);
	
@If (Manager="";@Prompt([OK];"Missing Data";"You must enter an approving manager");	@Success) ;
(If (Manager="";@Return("");@Success);
	
@If(@Prompt([YESNO];"Form Submission";"This form is about to be routed for approval to "+ 	Manager + ".  Are you sure you would like to send it now?");"";@Return(""));
FIELD Status := @If(Tentative!="Tentative";"Submitted for Approval";"Tentative Pending Approval");
@SetField("StatusDate"; @Today);
FIELD Author :=Manager;
FIELD NextApprover :=Manager;
FIELD LevelApproved :=0;
	
FIELD SendBack := @UserName;
@MailSend(SendTo;"";"";Tentative + " " + dspReqType + "  Request submitted for your approval";"";Name+" has submitted a " + Tentative + " " + dspReqType + " request for your approval. Please review:  ";[IncludeDoclink]);
@PostedCommand([FileSave]) ;
@PostedCommand([FileCloseWindow])

If you want to use LotusScript instead of formula language it would be more like this (this is from a different application):

Code:
Sub Postsave(Source As Notesuidocument)
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim newdb As NotesDatabase
Dim doc As NotesDocument
Dim maildoc As NotesDocument
Dim mailrtitem As NotesRichTextItem
Dim language As String, docket As String, fname As String, lname As String, interveiwer As String, notify As String
Dim Comments As String
Dim intdate As Variant
	
Set db = session.CurrentDatabase
Set servername = New NotesName(db.Server)
'Check organization of Requestor to know which domain to send to
domainmailfile = "mail.box"
Set newdb = session.GetDatabase(servername.Abbreviated, domainmailfile)
Set maildoc = New NotesDocument(newdb)
	
Set doc = source.Document
If (source.FieldGetText(&quot;InterviewLanguage&quot;) = &quot;Other&quot; And source.FieldGetText(&quot;OtherLanguage&quot;) <> &quot;&quot;) Then
'set admin personnel to receive notification
Dim recipients( 1 To 2 ) As String
recipients( 1 ) = &quot;Barbara Giannini&quot;
recipients( 2 ) = &quot;Bernadette Peck&quot;
		
If source.document.IsNewNote Then
language = source.FieldGetText(&quot;OtherLanguage&quot;)
docket = source.FieldGetText(&quot;DocketNo&quot;)
fname = source.FieldGetText(&quot;FirstName&quot;)
lname = source.FieldGetText(&quot;LastName&quot;)
intdate = source.FieldGetText(&quot;InterviewDate&quot;)
interviewer = source.FieldGetText(&quot;Interviewer&quot;)
			
maildoc.Form = &quot;Memo&quot;
maildoc.Subject = &quot;Translator Needed&quot;
			
maildoc.Body = &quot;Case Number: &quot; + docket + &quot;.      &quot; + fname + &quot; &quot; + lname  + &quot; , interviewed on &quot; + intdate + &quot; by &quot; + interviewer + &quot;, requires a &quot; + language + &quot; translator.  Thank you.&quot;
			
Call maildoc.Send( False, recipients )
Else
Exit Sub
End If
End If
	
If (source.FieldGetText(&quot;NoReleased&quot;) <> &quot;--No Selection&quot; And source.FieldGetText(&quot;Release&quot;) = &quot;Not Released&quot; And source.FieldGetText(&quot;Comments&quot;) <> &quot;&quot;) Then
'set pretrial supervisors to receive notification with DOCUMENT LINK
		
Dim recipients2 As String
recipients2 = &quot;Robert Padilla&quot;
		
If source.document.IsNewNote Then
Comments = source.FieldGetText(&quot;Comments&quot;)
docket = source.FieldGetText(&quot;DocketNo&quot;)
fname = source.FieldGetText(&quot;FirstName&quot;)
lname = source.FieldGetText(&quot;LastName&quot;)
intdate = source.FieldGetText(&quot;InterviewDate&quot;)
interviewer = source.FieldGetText(&quot;Interviewer&quot;)
			
maildoc.Form = &quot;Memo&quot;
maildoc.Subject = &quot;Supervisor Non-Release Review&quot;
			
Set mailrtitem = maildoc.CreateRichTextItem(&quot;Body&quot;)
Call mailrtitem.AppendText (&quot;Case Number: &quot; + docket + &quot;.      &quot; + fname + &quot; &quot; + lname  + &quot; , interviewed on &quot; + intdate + &quot; by &quot; + interviewer + &quot;, was not released.  Here are the comments &quot;_
			+  interviewer + &quot; wrote:  &quot; + Comments + &quot;     &quot;)
Call mailrtitem.AppendDocLink(doc, &quot;&quot;)
Call maildoc.Send( False, recipients2 )
Else
Exit Sub
End If
End If
If (source.FieldGetText(&quot;Treatment&quot;) = &quot;New&quot;) Then
'set pretrial supervisors to receive notification with DOCUMENT LINK
Dim recipients3( 1 To 3 ) As String
recipients3( 1 ) = &quot;Edwina Abeyta&quot;
recipients3( 2 ) = &quot;Peter Boyles&quot;
recipients3( 3 ) = &quot;David Martinez&quot;
		
If source.document.IsNewNote Then
docket = source.FieldGetText(&quot;DocketNo&quot;)
fname = source.FieldGetText(&quot;FirstName&quot;)
lname = source.FieldGetText(&quot;LastName&quot;)
intdate = source.FieldGetText(&quot;InterviewDate&quot;)
interviewer = source.FieldGetText(&quot;Interviewer&quot;)
			
maildoc.Form = &quot;Memo&quot;
maildoc.Subject = &quot;PTS Interview with Treatment&quot;
			
Set mailrtitem = maildoc.CreateRichTextItem(&quot;Body&quot;)
Call mailrtitem.AppendText (&quot;Case Number: &quot; + docket + &quot;.      &quot; + fname + &quot; &quot; + lname  + &quot; , interviewed on &quot; + intdate + &quot; by &quot; + interviewer + &quot;, has mental health issues. &quot;)
Call mailrtitem.AppendDocLink(doc, &quot;&quot;)
Call maildoc.Send( False, recipients3 )
Else
Exit Sub
End If
End If
Set doc = workspace.currentdocument.document
If doc.IsNewNote Then
Dim endTime As New NotesDateTime( &quot;&quot; )
Dim intend As String
endTime.LSLocalTime = Now
intend = endtime.TimeOnly
Call source.FieldSetText(&quot;EndTime&quot;, intend)		
End If
	
End Sub


HTH



Leslie
landrews@metrocourt.state.nm.us

There are 10 types of people in the world -
those who understand binary
and
those who don't!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top