Solved

LotusScrip help

Posted on 2006-06-13
7
575 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 19

Expert Comment

by:madheeswar
ID: 16894874
0
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

862 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now