Alfresco - Get username in workflow

∥☆過路亽.° 提交于 2019-12-12 18:52:27

问题


I'm searching for the username of assignees when I create on a workflow...

I use this:

public void notify(DelegateExecution execution) {
    // get value of property mymodel:myproperty 
    Object assignees = execution.getVariable("bpm_assignees"); 
}

When I get bpm_assignees I get this:

bpm_assignees map value: [Node Type: {alfresco.org/model/content/…}person, Node Aspects: [{alfresco.org/model/content/…}ownable, {alfresco.org/model/system/1.0}referenceable, {alfresco.org/model/system/1.0}localized], Node Type: {alfresco.org/model/content/…}person, Node Aspects: [{alfresco.org/model/content/…}ownable, {alfresco.org/model/system/1.0}referenceable, {alfresco.org/model/system/1.0}localized]]

How can I get username?


回答1:


Those objects are the Person NodeRefs. If you fetch back the properties from that node, you'll get things like the user's username, email address etc. You can see what properties are available by looking at the core content model (scroll down to cm:person)

Assuming the returned object is an ActivitiScriptNodeList, then they'll come handily wrapped up with accessors etc as they'll be ActivitiScriptNodes. Those extend the normal Alfresco JavaScript ScriptNode objects. That means that what you'd need to do is:

public void notify(DelegateExecution execution){
   ActivitiScriptNodeList assignees = execution.getVariable("bpm_assignees"); 
   for (ActivitiScriptNode personNode : assignees) {
       String username = personNode.getProperties().get("cm:userName");
       String email = personNode.getProperties().get("cm:email");
       // TODO Use this
   }
}


来源:https://stackoverflow.com/questions/33798544/alfresco-get-username-in-workflow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!