Solved

LotusScrip help

Posted on 2006-06-13
7
580 Views
Last Modified: 2013-12-18
Hey, can anybody help me out here, I'm drawing a blank for some reason!  

I want a lotusscript that will run and select a document from a custom domino directory and then change a value in the doc and save it. Basically its a password change custom form.  User will enter the username and a "company" name.  The script will find the correct document, automatically generate a password, update the internet password field, save the doc, send an email to the initiating user containing the username and password changes.  I've got everything but how to select the correct person document to update.  I was looking at GetDocumentByKey but I  need to have two "key" values and am kind of confused.  Can someone please straighten me out!!  Thanks!!!



Heres where I'm at so far:
      Dim doc As NotesDocument
      Set doc = Session.DocumentContext
      Set db = Session.Currentdatabase
      Dim db As NotesDatabase
      Dim Session As New NotesSession
      Dim workspace As New NotesUIWorkspace      
      Dim uidoc As NotesUIdocument

      Dim Username As String
      Dim Password As String
      
      Set uidoc = workspace.currentdocument
      Set db = New NotesDatabase("wtecdom","supusers.nsf")
      
      If uidoc.FieldGetText("FirstName") = "" Then
            Msgbox "You must enter the users first name.",,"Entry Error"
            Exit Sub
      End If
      If uidoc.FieldGetText("LastName") = "" Then
            Msgbox "You must enter the users last name.",,"Entry Error"
            Exit Sub
      End If
      If uidoc.FieldGetText("VendorNumber") = "" Then
            Msgbox "You must enter the users associated Vendor Number.",,"Entry Error"
            Exit Sub
      End If

      Username = Trim$(uidoc.FieldGetText("FirstName")) + Trim$(uidoc.FieldGetText("LastName"))
:
:
:
***code to gen password
:
***code to select doc based on Username and VendorNumber (this is what I really need!!!)
***set doc password to password
***save doc
***send email
 

Hope this isn't too confusing!! Thanks!!
0
Comment
Question by:NARoberts
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 18

Accepted Solution

by:
marilyng earned 125 total points
ID: 16895958
the problem that you're going to have is that the person can only update his person doc, if your NAB is configured that way.  Else, any agent that you attempt to run might not work because the user doesn't have access to the nab, or their person doc.


If they do, then you open the names.nsf (directory) on their mail server.
Find their name in the ($Users) view to find their person doc:
    Set nabdb = session.opendatabase(thisServer,"names.nsf")
     if not nabdb.isOpen then
      'some message error
      exit sub
     end if
   'Then check user's access permission for the database before you go further
     set nabview = nabdb.getview("($Users)"
     if nabview is nothing then exit sub
     Set persondoc = nabview.getdocumentbykey(lcase(session.username), true)
     If persondoc is nothing then
       'display message about error
     end if

0
 
LVL 3

Author Comment

by:NARoberts
ID: 16896156
This is a special directory for a special app.  Users will have the appropriate access.  It looks like this may work. I thought I needed a view I just didn't think there was one. I'll give it a shot.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Expert Comment

by:marilyng
ID: 16898953
Usually $Users will work, or VimUsers.  $Users sorts, lowercase all name variations so it will find: jane smith, jsmith, jane.smith/department/domain, etc.
0
 
LVL 3

Author Comment

by:NARoberts
ID: 16903280
Here is the code that I ended up with.  It seems to work ok except for one minor thing. When it does the final close notes asks if you want to save the form.  Is there anyway around this?  Guess its since I modified it.  I really don't want it saved, can I just close w/o saving?  Thanks!!!


      Dim db As NotesDatabase
      Dim Session As New NotesSession
      Dim workspace As New NotesUIWorkspace      
      Dim uidoc As NotesUIdocument
      Dim Username As String
      Dim Password As String
      
      Set uidoc = workspace.currentdocument
      Set db = New NotesDatabase("ServerName","supusers.nsf")
      
      If uidoc.FieldGetText("FirstName") = "" Then
            Msgbox "You must enter the users first name.",,"Entry Error"
            Exit Sub
      End If
      If uidoc.FieldGetText("LastName") = "" Then
            Msgbox "You must enter the users last name.",,"Entry Error"
            Exit Sub
      End If
      If uidoc.FieldGetText("VendorNumber") = "" Then
            Msgbox "You must enter the users associated Vendor Number.",,"Entry Error"
            Exit Sub
      End If
      
      Username = Trim$(uidoc.FieldGetText("FirstName")) + Trim$(uidoc.FieldGetText("LastName"))
      Call uidoc.FieldSetText("Username",username)
      
 'Then check user's access permission for the database before you go further
      Set  nabview = db.getview("($Users)")
      If nabview Is Nothing Then Exit Sub
      Set persondoc = nabview.getdocumentbykey(Lcase(Username), True)
      If persondoc Is Nothing Then
            Msgbox "Error"
      End If
      
      Call CreatePassword      
      persondoc.HTTPPassword = uidoc.FieldGetText("Password")
      
      success = persondoc.ComputeWithForm( False, False )
      success =  persondoc.Save( True , True )
      
      Set doc = New NotesDocument(db)
      doc.form = "Memo"
      doc.Sendto = uidoc.FieldGetText("Creator")
      doc.Subject = "User password reset"
      doc.Body =  "Username: " & Username & Chr(10) & "Password:  " & uidoc.FieldGetText("password") & Chr(10) & Chr(10) & "Please give this password to the vendor and delete the email as soon as possible." & Chr(10) & Chr(10) & "Thank you, " & Chr(10) & "Administrator"
      Call doc.Send(False)
      
      Call uidoc.Close
0
 
LVL 18

Expert Comment

by:marilyng
ID: 16904216
I really don't want it saved, can I just close w/o saving? << set a field, "SaveOptions" to "0" if you never want to save the form.   or set it programmatically before you  run the close method.
0
 
LVL 3

Author Comment

by:NARoberts
ID: 16904370
Awesome, works great!!
0

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

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

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

617 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