Dialog Box

Hi,

I am using a Dialog Box method to preview a copy of a letter that is sent to some users. I have used one form called MemoPreview to preview in the dialog box. I need to have a couple of changes when user see’s it.

  1. To Save the text that is added in the message area(which can be edited by the user), so if the template is to be previewed a second time the additional text will display.

  2. Also there is a attchment field on the main form. I want to display those attachments in the Dialog box.

  3. I am displaying a logo, if the users opts to have no Logo, the logo is not displayed but i see white space. I want to remove that space.

Here is the code that i have written,

Sub Preview(uidoc As notesuidocument,doc As notesdocument)

On Error Goto errHandler



dow(2)="Monday"

dow(3)="Tuesday"

dow(4)="Wednesday"

dow(5)="Thursday"

dow(6)="Friday"     







If uidoc Is Nothing Then

	Set uidoc=ws.currentdocument

End If

If doc Is Nothing Then

	Set doc=uidoc.document

End If





Set idv=db.getview("admin\ids")

Set iddoc=idv.getfirstdocument

Set idstor=iddoc.getfirstitem("IDFile")

homedir=s.getenvironmentstring("Directory",True)

keyfile=s.getenvironmentstring("KeyFilename",True)

usrid=homedir+"\"+keyfile

Forall o In idstor.embeddedobjects

	Call o.ExtractFile( homedir+"\"+o.name )

	fname=o.name

	Exit Forall

End Forall



doc.mode="Preview"

'Call uidoc.refresh 

Call uidoc.collapseallsections

Call uidoc.save

Set mdoc=db.createdocument

Set pvdoc=db.createdocument	

Set rtsrc=doc.getfirstitem("Body")



If doc.hasitem("$Fonts") Then              

	Set font=doc.getfirstitem("$Fonts")       

	Call pvdoc.CopyItem(font, "$Fonts")

End If



Set rttgt=pvdoc.CopyItem(rtsrc, "Body")         

pvdoc.subject="DRAFT:"+doc.subject(0)

pvdoc.form="MemoJPM"

mdoc.subject="DRAFT:"+doc.subject(0)

pvdoc.requestno=doc.requestno

pvdoc.requestdate=doc.requestdate

pvdoc.distdate=doc.distdate

pvdoc.disttime=doc.disttime     

pvdoc.subjfieldopt=doc.subjfieldopt

pvdoc.ccfieldopt=doc.ccfieldopt

pvdoc.bccfieldopt=doc.bccfieldopt

If doc.hasitem("DateStamp") Then

	If Isdate(doc.datestamp(0)) Then

		dsv=Cdat(doc.datestamp(0))	

	Else

		dsv=""

	End If

Else

	dsv=""

End If

If dsv<>"" Then

	Set dstime=New notesdatetime(Cstr(dsv))

	mm=Cstr(Month(dstime.dateonly))

	dd=Cstr(Day(dstime.dateonly))

	y=Cstr(Year(dstime.dateonly))

	dv=mo(mm)+" "+dd+", "+y

	Set ds = s.CreateRichTextStyle( )

	ds.NotesFont = FONT_HELV

	ds.FontSize = 10

	ds.Italic=False

	ds.underline=False

	ds.strikethrough=False

	ds.notescolor=COLOR_BLACK

	ds.bold=False		

	Call rttgt.AddNewLine(2)

	Call rttgt.AppendStyle( ds )

	

	Call rttgt.appendtext(dv)

End If	

Set iuo = s.CreateRichTextStyle( )

iuo.NotesFont = FONT_HELV

iuo.FontSize = 10

iuo.notescolor=COLOR_BLACK

iuo.bold=True   

iuo.Italic=False

iuo.underline=False

iuo.strikethrough=False

addiuostamp=False



If Trim(doc.getfirstitem("Audience").text)<>"" Then

	Set aud=doc.getfirstitem("Audience")				

	Call rttgt.AddNewLine(2)

	Call rttgt.AppendStyle( ds )

	Call rttgt.appendtext(aud.text)		

End If

Forall o In doc.getfirstitem("OtherMailOptions").values

	If o="Internal Use Only" Then

		addiuostamp=True

	End If

End Forall

If addiuostamp Then		

	Call rttgt.AddNewLine(2)

	Call rttgt.AppendStyle( iuo )

	Call rttgt.appendtext("FOR INTERNAL USE ONLY")

End If

pvdoc.principalnames=Trim(doc.messagefrom(0))+" "+Trim(doc.distwho(0))

'mdoc.principal=Trim(doc.distwho(0))

mdoc.principal=Trim(doc.principal(0))

If doc.contacts(0)="" Then

	mdoc.contacts=s.username     

Else

	mdoc.contacts = doc.contacts	

End If     

mdoc.approver=doc.approver

pvdoc.othermailoptions=doc.otherMailOptions



Call pvdoc.computewithform(False,False)

pvdoc.name = doc.Jlogo(0)'Added to hide the logo in the review mail

Call pvdoc.save(True,False)



mp1= |Please review the email below and reply with your approval or changes.

This email will be sent to:|+Chr(13)

dl=listmatch_nf(doc)

If Isarray(dl) Then		

	For r=0 To Ubound(dl)	

		If r=0 Then

			mp1=mp1+dl(r)

		Else

			mp1=mp1+","+dl(r)

		End If

	Next

Else		

	mp1=mp1+"No recipients selected"

End If

mp1=mp1+Chr(13)+Chr(13)	

mp1=mp1+"Thank you."

mdoc.distmsg=mp1



Set mrt=New NotesRichTextItem(mdoc , "Body")

Call pvdoc.RenderToRTItem(mrt)

Call mdoc.save(True,False)

flag= ws.DialogBox( "MemoPreview" , True,True, False, False, False, False, "Send a preview to the requester.",mdoc)

If flag Then        

	mdoc.form="MemoPreview" 

	doc.approver=mdoc.approver

	doc.contacts=mdoc.contacts

	

	mdoc.sendto=mdoc.approver

	mdoc.replyto=mdoc.contacts

	mdoc.svr=db.server

	mdoc.db=db.filepath

	mdoc.tuid=doc.universalid

	Call mdoc.save(True,False)		

	Call mdoc.send(True,mdoc.getfirstitem("Approver").values)

	Call doc.save(True,False)		

End If            

Call pvdoc.remove(True)

Call mdoc.remove(True)

sd:

Exit Sub

errHandler:

Messagebox "The error is in SUB Preview. The error is  : " & Str(Err) & " - " & Error$ &  " at line number " & Cstr(Erl) & Chr(10) & Chr(10) &"  The code execution will be terminated. Contact Database Support team for assistance."

Resume sd

End Sub

Subject: already posted