Solved

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

Posted on 2008-06-25
9
293 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
[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
  • 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
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.

 

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
 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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…
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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

617 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