How can we get approvers name who has approved a workflow step for a workflow who belongs to a publisher group.
Solved! Go to Solution.
Hi,
you meant last task approved by users? If Yes you can try below code
Note : below code only check last task if want to check all you can loop through by list.
List<HistoryItem> historyList = session.getHistory(item.getWorkflow());
int listSize = historyList.size();
// log.info("listSize = {}", listSize);
HistoryItem lastItem = historyList.get(listSize - 1);
String lastComment = lastItem.getComment();
String lastAction = lastItem.getAction();
String lastUser = lastItem.getUserId();
Views
Replies
Total Likes
You can search the AEM Workflow API -- com.adobe.granite.workflow.exec ("The Adobe AEM Quickstart and Web Application.")
Views
Replies
Total Likes
Hi,
you meant last task approved by users? If Yes you can try below code
Note : below code only check last task if want to check all you can loop through by list.
List<HistoryItem> historyList = session.getHistory(item.getWorkflow());
int listSize = historyList.size();
// log.info("listSize = {}", listSize);
HistoryItem lastItem = historyList.get(listSize - 1);
String lastComment = lastItem.getComment();
String lastAction = lastItem.getAction();
String lastUser = lastItem.getUserId();
Views
Replies
Total Likes
Arun - does that code show the WF user whom approved the payload as shown here.
Views
Replies
Total Likes
If so - that would make a nice artilce - i searched the Java docs and talked to ppl. I am going to test this.
Views
Replies
Total Likes
Hi Scott,
I think, we can read all the properties of transitions. For example below property can be read using JCR Node API
Node n = session.getSession().getNode(lastItem.getWorkItem().getId());
Below is example of process step which simply add all history task in DB in form of json
aem63app-repo/WriteWFdetailsInDBProcess.java at master · arunpatidar02/aem63app-repo · GitHub
Views
Replies
Total Likes
I tested this code and it did report whom approved the workflow --
//Gets the User from approves the payload
private String getUserWhomApproved(WorkflowSession wfsession,WorkItem item)
{
try{
List<HistoryItem> historyList = wfsession.getHistory(item.getWorkflow());
int listSize = historyList.size();
// log.info("listSize = {}", listSize);
HistoryItem lastItem = historyList.get(listSize - 1);
String lastComment = lastItem.getComment();
String lastAction = lastItem.getAction();
String lastUser = lastItem.getUserId();
return lastUser;
}
catch (Exception e)
{
e.printStackTrace() ;
}
return "error - no user" ;
}
We captured this information that Arun provided in this related HELPX article -- https://helpx.adobe.com/experience-manager/using/aem64_workflow_servlet.html