Solved

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

Posted on 2008-06-25
9
287 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Missing Rules 1 298
Send email and attachment (Lotus notes) 55 240
DIIOP IP Addresses Changes Automatically 5 83
Code for extraction to mkdir folder 5 59
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 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

10 Experts available now in Live!

Get 1:1 Help Now