Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

LotusScrip help

Posted on 2006-06-13
7
Medium Priority
?
585 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 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
Independent Software Vendors: 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

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…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

722 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