cancel
Showing results for 
Search instead for 
Did you mean: 

display full user name instead of user id in document details

pmverma
Champ in-the-making
Champ in-the-making
Hi,

In document details, to display document Creator, we use "cm:creator" in form configuration for "cm:content".

At this point, I want to display the full username instead of its id.

Is this possible?

if(yes)
{
How it can be achieved?
} else
{
// thank you
}

Thanks in advance.
4 REPLIES 4

afaust
Legendary Innovator
Legendary Innovator
Hello,

this is possible, but not with any of the out-of-the-box control templates last I've checked. You can implement your own control template and associated client JS component, which would lookup the properties of a user based on the user name, and replace the user ID with the constructed full name once values have been loaded.

Regards
Axel

pmverma
Champ in-the-making
Champ in-the-making
Thank you Axel for you quick reply.

I also was guessing to use custom template. Your reply to use control make me more clear.
I will try in this way.

Thanks.

jpfi
Champ in-the-making
Champ in-the-making
Hi,
your custom person.ftl from control (view mode)may look like this:

<div class="form-field">

   <#if form.mode == "view" || field.disabled>
      <div class="viewmode-field">
         <span class="viewmode-label">${field.label?html}:</span>
         <span class="viewmode-value" id="${fieldHtmlId}-value"></span>
      </div>
      <#if field.value??>
      <script type="text/javascript">//<![CDATA[
      (function()
      {
          var updateElementWithUserMetadata = function(userNames, element)
          {
              if (userNames.length > 0)
              {
                  var userName = userNames.pop();
                  Alfresco.util.Ajax.jsonRequest(
                  {
                      method : "GET",
                      url : Alfresco.constants.PROXY_URI + "api/people/" + userName,
                      successCallback :
                      {
                          fn : function(response)
                          {
                              var name = "";
                              if (response.json.firstName)
                              {
                                  name += response.json.firstName;
                              }
                              if (response.json.firstName && response.json.lastName)
                              {
                                  name += " ";
                              }
                              if (response.json.lastName)
                              {
                                  name += response.json.lastName;
                              }
                              if (!name)
                              {
                                  name = userName;
                              }
                              if (element.innerHTML)
                              {
                                 element.innerHTML += ", ";
                              }
                              element.innerHTML += Alfresco.util.userProfileLink(userName, name, "", false);
                             
                              if (userNames.length > 0)
                              {
                                  updateElementWithUserMetadata(userNames, element);
                              }
                          },
                          scope: this
                      },
                      failureCallback :
                      {
                          fn : function(response)
                          {
                              if (element.innerHTML)
                              {
                                 element.innerHTML += ", ";
                              }
                              element.innerHTML += userName;
                              if (userNames.length > 0)
                              {
                                  updateElementWithUserMetadata(userNames, element);
                              }
                          },
                          scope: this
                      }
                  });
              }
          };
          YAHOO.util.Event.onContentReady("${fieldHtmlId}-value", function ()
         {
            var element = YAHOO.util.Dom.get("${fieldHtmlId}-value");
              element.innerHTML = "";
              var fieldValue = "${field.value?html}";
              if (fieldValue)
              {
                  var userNames = fieldValue.split(",");
                  updateElementWithUserMetadata(userNames, element);
              }
         }, this);
          /**/
      })();
      //]]>
      </script>
      </#if>
   </#if>
</div>

pmverma
Champ in-the-making
Champ in-the-making
Thank you Jan,

Your comment and code are really helpful.
I very much appreciated it.

Thanks again.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.