Manage Learn to apply best practices and optimize your operations.

Extracting & displaying a picture in Notes client at runtime

I had a peculiar problem in my application where I had to display the pic of the user logged in.

I had a peculiar problem in my application where I had to display the pic of the user logged in. The pic of the concerned employee was to be picked up from his profile document. I was able to do it easily in the Web version of the application, but the Notes client version posed a problem. Here is how I solved it & thought would share it with u all too....

* The pic of the employee is saved as an attachment in this profile doc in a RTField named "attach".
* The same pic has to be displayed on a form as soon as the person logs in and enters his application.

Write this code in the "postopen" event of the form where the pic has to be displayed...


Sub Postopen(Source As Notesuidocument)
	Dim s As New notessession	
	Dim ws As New notesuiworkspace
	Dim uidoc As notesuidocument
	Dim doc,mdoc As NotesDocument
	Dim db,mdb As notesdatabase
	Dim view As notesview
	Dim rtitem As Variant
	Dim item,item1 As notesitem
	Dim a1,path,Lesson,ext,subext As String
	Set db =s.currentdatabase
	server$=db.server
	filepath$=db.filepath
	Dim name1 As New notesname(db.server)
	
	dir1$=Strleftback(filepath$,"")
	If dir1$<>"" Then
		directory$= dir1$+""
	Else
		directory$= dir1$
	End If
	
	Set mdb = New notesdatabase(server$ , Trim(directory$+ "Master.nsf"))// Master is the database where the profile doc is saved.
	Set view = mdb.getview("(view name for profile doc sorted on common user name)")
	Set mdoc = view.getdocumentbykey(s.commonusername)	
	If Not mdoc Is Nothing Then
		
		Set uidoc=ws.currentdocument
		
		Set rtitem = mdoc.GetFirstItem("attach")// RTField in profile doc
		
		If ( rtitem.Type = RICHTEXT ) Then
			Forall o In rtitem.EmbeddedObjects
				If ( o.Type = EMBED_ATTACHMENT) Then
					
					Call o.ExtractFile _
					("c:\temp\"&Cstr(s.commonusername) )
					Call uidoc.gotofield("picture")// Rtfield in display form
					Call uidoc.Import( "GIF Image","c:\temp\"&Cstr(s.commonusername))
				End If
			End Forall
		End If
		Kill "c:\temp\"&Cstr(s.commonusername)
		Call uidoc.refresh
		
	End If
	'Call uidoc.close
End Sub
* Do make sure that the save options of this display form are set to "0"

Dig Deeper on Domino Resources - Part 7

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close