Hi Phillip,
Basically, what I am looking for is the ability to write the name of the person who approved the stage that the workflow document is at.
I did add some code to my source. The only part I'm questioning is whether or not cycling through all of the States is necessary. Here is the code that I added:
<b>State.java</b>
final static String APPROVED_BY_FIELD = "rwfApprovedByField";
/**
- Return the value in the Approved By field associated with the state
- This method will return the value in the Approved By field. The intent of the field
- is to essentially be used to write the name of the person who approved the current state
- @return The field value from the state
*/
public String getApprovedByField()
{
try
{
if (stateDoc.hasItem(State.APPROVED_BY_FIELD))
{
return stateDoc.getItemValueString(State.APPROVED_BY_FIELD);<br/>
}
}catch(NotesException e){e.printStackTrace();}
return null;
}
<b>Approver.java</b>
/**
- Set the name of the current approver in the context document
- The value of the approvedByField can be taken from an existing State document
- and the State class has a method specifically for returning this value.
- @param approvedByField The field to set on the underlying context document
*/
public void setApprovedByField(String approvedByField)
{
try
{
String n = ses.getUserName();<br/>
/// grab the username from the REMOTE_USER cgi variable for web apps.<br/>
if(doc.hasItem("REMOTE_USER") && doc.getItemValueString("REMOTE_USER") != null){<br/>
n = doc.getItemValueString("REMOTE_USER"); <br/>
if(doc.getItemValueString("REMOTE_USER").trim().equals("")){n = "Anonymous";} <br/>
}<br/>
else<br/>
{<br/>
// we want the name to look nice, so write the abbreviated<br/>
// version<br/>
Name currentUser = ses.createName(n);<br/>
n = currentUser.getAbbreviated();<br/>
}<br/>
doc.replaceItemValue(approvedByField, n);<br/>
}
catch (NotesException e)
{
}
}
<b>WorkflowDocument.java</b>
/**
- Set the approved by field for the workflow document
*/
public void setApprovedBy()
{
// Note: I'm a little unsure about the cycling through the States - Eric
for(Iterator it=states.iterator(); it.hasNext(); )
{
State s = (State)it.next();<br/>
String approvedByField = s.getApprovedByField();<br/>
<br/>
approver.setApprovedByField(approvedByField);<br/>
}
}
And one modification to the processContextDoc method:
WorkflowDocument wfd = new WorkflowDocument(doc);
boolean save = false;
if(wfd.runValidation()){
if(wfd.hasChangedStatus()){<br/>
wfd.setApprovers();<br/>
wfd.setAuthors();<br/>
wfd.setReaders();<br/>
wfd.sendMail();<br/>
wfd.setHistory();<br/>
wfd.setApprovedBy(); // <-- I added this part<br/>
}<br/>
Of course, finally you need to modify the State document to include a field with the name "rwfApprovedByField".
Thanks,
Eric