Solved

Require an agent to replace the contents of  a field within a view

Posted on 2008-06-25
9
285 Views
Last Modified: 2013-12-18
I am required to change the contents of a name field from "john smith" to "Peter Brown" and there are hundreds of records within the database.

A manual Find and replace within the view does not work.

The View is selected from a form labelled "Lookup" and the field that is required to be changed is labelled "Line Manager" and appears in many records within the database.

Hoping to introduce an agent to complete this task to make life easy. Please assist with script if possible.


Thanks for you help
0
Comment
Question by:ianmcalder
  • 4
  • 4
9 Comments
 
LVL 19

Expert Comment

by:madheeswar
ID: 21872231
First, take a backup of the db with docs.
create a view and have a selection formulae:
SELECT Form="Lookup" & LineManager="John Smith"

this will display all the docs with "John Smith". NOw create an action button.
FIELD LineManager:=LineManager;
@SetField("LineManager";"Peter Brown")
Save the design and preview in Notes client.
Select all the docs in the view and click on the action button. Press F9 to refresh and you should see that all the docs should get vanished from the view. It means the change does happened.
0
 

Author Comment

by:ianmcalder
ID: 21880207
I have created the view that works however the action button does not change the field within the view using sujested formula attached to button.

FIELD LineManager:=LineManager;
@SetField("LineManager";"Peter Brown")
0
 

Expert Comment

by:jareddraper
ID: 21886784
Give this a try, I would make a button in your view that includes this code


Sub Click(Source As Button)
      Dim workspace As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim view As NotesView

        Set db = session.CurrentDatabase
      Set view = db.GetView( "Lookup" )
      Set doc = view.GetFirstDocument

Do Until doc Is Nothing
            'open the current document for editing
            Set uidoc = workspace.EditDocument(True, doc)

'Check the current value of the field
              vCurrentValue = uidoc.FieldGetText("Line Manager")
'If it equals John Smith then change to Peter Brown
              If vCurrentValue = "John Smith" Then

                     call uidoc.FieldSetText("Line Manager", "Peter Brown")

               EndIf

'Get the next document
            Set doc = view.GetNextDocument(doc)

Loop
            
0
 

Expert Comment

by:jareddraper
ID: 21886797
Opps forgot a part...you need to save and close the doc...use this code

Sub Click(Source As Button)
      Dim workspace As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim view As NotesView

        Set db = session.CurrentDatabase
      Set view = db.GetView( "Lookup" )
      Set doc = view.GetFirstDocument

Do Until doc Is Nothing
            'open the current document for editing
            Set uidoc = workspace.EditDocument(True, doc)

'Check the current value of the field
              vCurrentValue = uidoc.FieldGetText("Line Manager")
'If it equals John Smith then change to Peter Brown
              If vCurrentValue = "John Smith" Then

                     call uidoc.FieldSetText("Line Manager", "Peter Brown")

               EndIf

                Call uidoc.Refresh
            Call uidoc.Save
            Call uidoc.Close
            Call uidoc.Close

'Get the next document
            Set doc = view.GetNextDocument(doc)

Loop

End Sub
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.

 

Author Comment

by:ianmcalder
ID: 21895703
Hello Jareddraper

Thanks for your response however I receive this error when attempting to save view with new code attached to button. I am not familiar with lotus script therefore can not resolve script error myself.

Error:
Lotus_Script: Click:33:Unexpected:Loop:Expected:END IF

0
 

Expert Comment

by:jareddraper
ID: 21896345
Looks like I made a typo...on the line that says "EndIf" change it to "End If"   You need a space in there.  The other thing I wasn't too sure of is you need to check what the name of the view you are trying to use is set with the line Set view = db.GetView("Lookup")  I kind of assumed the name of your view was lookup but wasn't sure
0
 

Author Comment

by:ianmcalder
ID: 21896504
Hello jareddraper

All looking good only one hiccup remains  the sript seems to change  one record only even though I am selecting multiple records from the "Lookup" view, there are thousands of records therefore idealy would like to automate processing all records.

A Notes  error pops up after processing the first record successfully reading  "Notes error: Entry not found in index (Lookup)  I select OK then the scipt terminates. It doe not seem to go onto the next selected record.
0
 

Accepted Solution

by:
jareddraper earned 125 total points
ID: 21896604
It sounds like it can't find the view named Lookup, might check to make sure you have a view named that.  What is troubling to me is that you said it successfully processes the first document.  You might try turning Debug LotusScript on, to do that click File then Tools then click Debug LotusScript.  Do this before opening your database then try clicking the button you created, see which line it errors out on.  Hope this helps
0
 

Author Closing Comment

by:ianmcalder
ID: 31470853
Thanks for you help. Your solution was of assistance.
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

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.
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 is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 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

16 Experts available now in Live!

Get 1:1 Help Now