Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2008-06-25
9
Medium Priority
?
300 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
Industry Leaders: 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!

 

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 375 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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…
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.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

876 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