Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

LotusScrip help

Posted on 2006-06-13
7
Medium Priority
?
586 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
  • 3
  • 3
7 Comments
 
LVL 18

Accepted Solution

by:
marilyng earned 500 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

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

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…
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

926 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