?
Solved

How update a person document in the Domino Directory based on form input

Posted on 2007-08-09
10
Medium Priority
?
1,386 Views
Last Modified: 2013-12-18
I have restricted access to our Domino Directory so that users only have "Reader" access.  However, I want the users to be able to update their contact information on the "Work" tab of their person documents.  I would like to create a form listing the fields on "Work" tab of the person document and provide this form to the users in a database.  

How can I accomplish the following:
1.  When the user creates a document using the form, automatically populate the fields with the current values in the user's person document and allow certain users to change this information on behalf of another user.
2.  After the user makes changes to the field values, save and close the document then have an agent run against these documents and update the users' person document in the Domino Directory using the "Employee ID" as the key.

I am a beginner using Lotusscript so any code you can provide would greatly appreciated.
0
Comment
Question by:niccilaw
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 19

Assisted Solution

by:madheeswar
madheeswar earned 600 total points
ID: 19662328
Below is the agent which u need to schedule. Sign the agent with Admin id.
Dim s As New NotesSession
      Dim view As notesView, currview As notesview
      Dim queue As notesDocumentCollection
      Dim keyValue As String, dataValue As String
      Dim src As notesDocument, target As notesDocument
      Dim here As notesDatabase
      Dim there As New NotesDatabase("servername","path\filename.nsf") 'Give your NAB details
      
      
      Set view = there.getView("name of some view that sorts on key value")
      
      Set here = s.currentDatabase
      Set currview= here.GetView("name of some view ")
      Set src = currview.getFirstDocument
      
      Do Until src Is Nothing
            keyValue = src.getItemValue("name of some field containing the key value")(0)
            'dataValue = src.getItemValue("name of some field containing the value to copy")(0)
            Set target = view.getDocumentByKey(keyValue)
            If Not target Is Nothing Then
                  target.replaceItemValue "name of field to change" , dataValue
                  target.Save True , True
            End If
            Set src = currview.getNextDocument(src)
      Loop
      
0
 
LVL 63

Assisted Solution

by:SysExpert
SysExpert earned 200 total points
ID: 19662514
madheeswar has great code, but it may be missing some stuff.

1) You need a field with a status so that the agent only updates the changed docs in your database.
2) the section
 'dataValue = src.getItemValue("name of some field containing the value to copy")(0)
            Set target = view.getDocumentByKey(keyValue)

needs to be repeated for all the fields you want to update.

The view used should oly have changed docs, and use the status field to determine that, ie everytime a change is made, the status is changed to "updated", and when the agent is run it is either set to "" or "closed".

I hope this helps !
0
 
LVL 22

Accepted Solution

by:
Bill-Hanson earned 1200 total points
ID: 19664720
I would recommend creating a simple database with a sinlge form where users post their requests.  Once a request has been created in the database, a background agent will update the documents in the NAB, then delete the request document.  Madheeswar's agent above should do the trick.  Just be sure to add a line that deletes the request document (or mark it processed like SysExpert recommends, but your database will continue to grow if you leave them in there).

Most users will only need only depositor access since this database will not contain any documents except those that have not yet been been processed by the backend agent.

The form needs to contain a field to identify the user (Editable for priveleged users, computed when composed for standard users) and any other fields that you want the user to be able to update.

Here's how I would code the agent.  This example should work, but you will need to supply your own settings and add error handling.

      Dim sess As New NotesSession()
      Dim db As NotesDatabase
      Dim nab As New NotesDatabase("", "")
      Dim view As NotesView
      Dim dc As NotesDocumentCollection
      Dim docRequest As NotesDocument
      Dim docNext As NotesDocument
      Dim docPerson As NotesDocument
      
      Const NAB_SERVER_NAME = "Server1/Acme"
      Const NAB_FILE_NAME = "names.nsf"
      
      Set db = sess.CurrentDatabase
      Set dc = db.UnprocessedDocuments
      If (dc.Count = 0) Then Exit Sub
      If Not nab.Open(NAB_SERVER_NAME, NAB_FILE_NAME) Then Error 2000, "Unable to open the Domino Directory."
      Set view = nab.GetView("($Users)")
      
      Set docRequest = dc.GetFirstDocument()
      Do While (Not docRequest Is Nothing)
            
            Set docNext = dc.GetNextDocument(docRequest)
            Set docPerson = view.GetDocumentByKey(docRequest.GetItemValue("UserName")(0), True)
            If (docPerson Is Nothing) Then
                  ' Need to add error handling here.
            Else
                  
                  ' Here is where you update the Person document.
                  docPerson.PhoneNumber = docRequest.GetItemValue("PhoneNumber")(0)
                  ' Continue updating the fields here...
                  Call docPerson.Save(True, False)
                  
            End If
            
            Call docRequest.Remove(True)
            Set docRequest = docNext
            
      Loop


0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 31

Expert Comment

by:qwaletee
ID: 19673166
FYI to all: No need to "schedule" this.  Instead, have the agent RunOnServer.  It can check the signature of the saved document to verify that the owner or an admin has made the edits, then apply the changes in real time. You can even have the editor DB switch the user to viewing his own Person document in the NAB when done, for instant feedbacl and gratification.

Nice, no?
0
 
LVL 22

Expert Comment

by:Bill-Hanson
ID: 19673806
FYI Pt 2: RunOnServer will work asuming the users are working from the server.  If they are working from a local replica, it will not.
0
 

Author Comment

by:niccilaw
ID: 19681937
I am working on implementing your proposed solutions, but I was wondering if you all thought the code should have a way to compare the old person document values with the new ones?  In the form I created, I have a table where the current person document information is displayed on one side and the user can input changes to their person document on the other side.  I tried modifying the code to include a way to compare the values, but I cannot figure out how to compare two variants or convert them to a string so I can compare them.
0
 
LVL 63

Expert Comment

by:SysExpert
ID: 19684041
Why is a compare needed ?

If you populate the fields with the original data, and then update the person doc with new data, why is a comparison needed anywhere ?

0
 

Author Comment

by:niccilaw
ID: 19684710
I just did not want the code rewriting information that has not changed. Maybe I am overthinking this.  One more thing, one of the fields contains an attachment.  How can I modify the code to update the attachment?  
0
 
LVL 63

Expert Comment

by:SysExpert
ID: 19685095
SInce this  Q has already been answered and closed, I would suggest opening a new Q for this.


0
 
LVL 31

Expert Comment

by:qwaletee
ID: 19687546
1) All teh values from fiels on both sides will be in arrays, you need to (typically) compare element zero of both sides

2) Notes is pretty efficient about the procesisng of changed and unchanged values, so it is probably not necessary

3) You can do it with attachments as well, but that will probably need a bit more specific coding

4) SysExpert is correct, any additional stuff is probably more approapriate in a new Q, but don't sweat that too much
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
Screencast - Getting to Know the Pipeline
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question