RealWorkFlow - Feature Request: Request for 'approved by' field| Created on |
Jun 11, 2006 |
| Created by |
Eric Borisow |
| Status |
Submitted |
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);
}
}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();
/// grab the username from the REMOTE_USER cgi variable for web apps.
if(doc.hasItem("REMOTE_USER") && doc.getItemValueString("REMOTE_USER") != null){
n = doc.getItemValueString("REMOTE_USER");
if(doc.getItemValueString("REMOTE_USER").trim().equals("")){n = "Anonymous";}
}
else
{
// we want the name to look nice, so write the abbreviated
// version
Name currentUser = ses.createName(n);
n = currentUser.getAbbreviated();
}
doc.replaceItemValue(approvedByField, n);
}
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();
String approvedByField = s.getApprovedByField();
approver.setApprovedByField(approvedByField);
}
}
And one modification to the processContextDoc method:
WorkflowDocument wfd = new WorkflowDocument(doc);
boolean save = false;
if(wfd.runValidation()){
if(wfd.hasChangedStatus()){
wfd.setApprovers();
wfd.setAuthors();
wfd.setReaders();
wfd.sendMail();
wfd.setHistory();
wfd.setApprovedBy(); // <-- I added this part
}
Of course, finally you need to modify the State document to include a field with the name "rwfApprovedByField".
Thanks,
Eric
Taken Actions by OwnersNo actions have been taken yet.Documents