Solved

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

Posted on 2008-06-25
9
283 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

760 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

22 Experts available now in Live!

Get 1:1 Help Now