Add value in an authors field with button click

AliciaVee
AliciaVee used Ask the Experts™
on
I have a button that updates the value of an author's field to a role.  this works fine as shown in code #1.  I now want to add the creator of the document, back as the author at the end of a review cycle.  The field that holds the creator's name, which is a "names" field is where I'm trying to take the value.  What I came up with in code #2, doesn't work and places a null string in the DocAuthor field.  Can someone help?
Code #1 -- updates the DocAuthor field when using a role:
	
	Dim w As New NotesUIWorkspace
	Dim uidoc As NotesUIDocument
	Dim doc As NotesDocument
	Dim AuthorRole As String
	AuthorRole = "[Recommend]"
	Set uidoc = w.CurrentDocument
	Set doc = uidoc.Document
	Call ChangeStatus("Verified","ApprovedBy", "ApprovedDate")
	Call SendNotice ("NotifyMsg1", doc)
	Set item = doc.ReplaceItemValue("DocAuthor",  AuthorRole)
	doc.Save True, True
	uidoc.Save
	uidoc.Close
	

Code #2 -- does not update the original author's name into the DocAuthor field:

	Dim w As New NotesUIWorkspace
	Dim uidoc As NotesUIDocument
	Dim doc As NotesDocument
	Dim AuthorRole As String
	AuthorRole = RequestBy
	Set uidoc = w.CurrentDocument
	Set doc = uidoc.Document
	Call ChangeStatus ("Move to Inventory", "", "")
	Call SendNotice ("NotifyMsg3", doc)
	Set item = doc.ReplaceItemValue("DocAuthor",  AuthorRole)
	doc.Save True, True
	uidoc.Save
	uidoc.Close

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
This is where the culprit is    AuthorRole = RequestBy
Place the abovce after this line:
 Set doc = uidoc.Document
AuthorRole = doc.RequestBy(0)
Since it is an Author field (DocAuthor), I presume you are storing the Canonical format of the author name in the RequestBy field.
I hope in the RequestBy ComputedWhenComposed field, you are using
@Name([CN]; @UserName)
If you want to update the the last edited author name, change the RequestBY field to Computed.
Else, simply, you can create a Authors field and use the code as specified.

Author

Commented:
Worked perfectly! Thanks very much!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial