Solved

LotusScrip help

Posted on 2006-06-13
7
574 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
Comment Utility
0
 
LVL 18

Accepted Solution

by:
marilyng earned 125 total points
Comment Utility
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
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 18

Expert Comment

by:marilyng
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Awesome, works great!!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 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

15 Experts available now in Live!

Get 1:1 Help Now