Link to home
Start Free TrialLog in
Avatar of AliciaVee
AliciaVee

asked on

Add value in an authors field with button click

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

ASKER CERTIFIED SOLUTION
Avatar of madheeswar
madheeswar
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of AliciaVee
AliciaVee

ASKER

Worked perfectly! Thanks very much!