Code to change field

Anyone with any ideas or pointers on creating an agent to update a field within a document.I.E. I have a view that displays all documents with field mailaddress if it contains @smith.com

I want to select records in this view and change the field mailaddress to replace @smith.com with @jones.com

so that billy.bob@smith.com becomes billy.bob@jones.com

Subject: Code to change field

You should be able to use some simple formula.

Create an Agent set to run on selected documents.

If you are manually selecting the documents you want changed from your view, your code should be something like this. (Also note: You want to grab the portion left of the @ symbol and add it to “@jones.com”. Also note you could create something more complex if you need to handle more conditions or domain addresses.)

Code:

Field mailaddress = mailaddress;

@SetField(“mailaddress” ; @LeftBack(mailaddress ; “@”) + “@jones.com”)

Randy Pearson

Subject: Replaceitemvalue…

Dim s As New notessession Dim db As notesdatabase

Dim view As notesview

Dim doc As notesdocument

Dim item, item1, item2, item3 As notesitem

Dim x As String



Set db = s.currentdatabase

Set view = db.getview("PO's")



Set doc = view.getfirstdocument



While Not (doc Is Nothing)

	Set item = doc.getfirstitem("approver")

	Set item1 = doc.getfirstitem("creator")

	Set item2 = doc.getfirstitem("authors")

	Set item3 = doc.getfirstitem("fullcreator")

	

	x  = item.values(0)

	y  = item1.values(0)

	z  = item2.values(0)

	t  = item3.values(0)

	

	If x = "someone's name" Then

		Call doc.ReplaceItemValue ("approver", "someone's name")

	End If

	If y = "someone's name" Then

		Call doc.ReplaceItemValue ("creator", "someone's name")

	End If

	If z = "someone's name" Then

		Call doc.ReplaceItemValue ("authors", "someone's name")

	End If

	If t = "someone's name" Then

		Call doc.ReplaceItemValue ("fullcreator", "someone's name")

	End If

	

	Call doc.save(True, True)		

	

	

	Set Nextdoc = view.getnextdocument(doc)

	Set doc= N

Subject: Agent target All documents in View.

Formula:SELECT @All;

FIELD MailAddress := @ReplaceSubString(MailAddress; “@smith.com”; “@jones.com”);

Subject: RE: Agent target All documents in View.

This worked perfectly, thank you Bill.