Search code examples
alfrescoalfresco-sharealfresco-webscripts

How to display all the properties of the selected reviewers?


Consider the business process "Review and Approve (one or more reviewers) - Assign a review task to multiple reviewers".

When I choose reviewers I see only their properties cm:userName. How to display all the properties of the type cm:person?

For example:

cm:userName
cm:firstName
cm:middleName
cm:email
cm:organizationId
cm:jobtitle
cm:googleusername

And so on...

Instead of this container (part of the association.ftl):

...
<div id="${controlId}-currentValueDisplay" class="current-values"></div> 
...

I would like to use table. IMHO for that I should override some parts of the Alfresco.ObjectFinder, such as:

if (this.options.displayMode == "items")
{
   Dom.get(this.id + "-currentValueDisplay").innerHTML = displayValue;
}

...etc. But how to display all the properties of the selected reviewers?

Let's say, this part:

displayValue += 
    this.options.objectRenderer.renderItem(
        item, 
        16, 
        "<div class='itemtype-" + $html(item.type) + 
        "' style='word-wrap: break-word;'>{icon} {name}</div>"
    );

I assume that it's property is name

Ok, then where to find the mapping "property in object-finder : property in the person type"?


Solution

  • To display the companyname, email etc fields to you need to modify the following files in the repo side.

    C:\Alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\extension\templates\webscripts\org\alfresco\repository\forms\pickerresults.lib.js
    
    C:\Alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\extension\templates\webscripts\org\alfresco\repository\forms\pickerresults.lib.ftl
    

    In the pickerresults.lib.js, I added the required extra properties in the CreatePersonResult(node) method.

    function createPersonResult(node)
    {
       var personObject = 
       {
          typeShort: node.typeShort,
          isContainer: false,
          properties: {},
          displayPath: node.displayPath,
          nodeRef: "" + node.nodeRef
       }
    
       // define properties for person
       personObject.properties.userName = node.properties.userName;
       personObject.properties.name = (node.properties.firstName ? node.properties.firstName + " " : "") + 
          (node.properties.lastName ? node.properties.lastName : "") +
             " (" + node.properties.userName + ")";
       personObject.properties.jobtitle = (node.properties.jobtitle ? node.properties.jobtitle  : "");
       //Add the extra properties here
       personObject.properties.organization =(node.properties.organization ? node.properties.organization  : "");
       personObject.properties.googleusername =(node.properties.googleusername ? node.properties.googleusername  : "");   
    
       return personObject;
    }
    

    In the pickerresults.lib.ftl, I added the extra properties to the result set, below to the "selectable" : ${row.selectable?string}</#if>

    "nodeRef": "${row.item.nodeRef}"<#if row.selectable?exists>,
    "selectable" : ${row.selectable?string}</#if>,
    "company": "${row.item.properties.organization!""}",
    "googleusername": "${row.item.properties.googleusername!""}",
    "jobtitle": "${row.item.properties.jobtitle!""}"
    

    enter image description here

    Hope this helps you now.