Forum Discussion

Myko_P's avatar
Myko_P
Expert
7 years ago

How to change the date format only for the messages of registered authors?

Hi, I am trying to make our community custom author component to change the date format only for registered authors messages, not for the anonymous. Got the following FreeMarker error:   Freemarke...
  • VikasB's avatar
    7 years ago

    Myko_P

    Check the updated code

    <#if env.context.message.uniqueId gt 0>
    <#assign messageAuthorId = rest("/messages/id/${env.context.message.uniqueId}/author").user.id />
    <#assign messageAuthorLogin = rest("/messages/id/${env.context.message.uniqueId}/author").user.login />
    <#assign badges = rest("/users/id/${messageAuthorId}/badges") />
    <#assign badgesCount = badges.user_badges.user_badge?size />
    <#assign avatarUrl = rest("/users/id/${messageAuthorId}/profiles/avatar/url").value />
    <#assign kudosCount = rest("/users/id/${messageAuthorId}/kudos/received/count").value />
    <#assign postCount = rest("/users/id/${messageAuthorId}/posts/count").value />
    <#assign blogCount = rest("/users/id/${messageAuthorId}/posts/style/blog/count").value />
    <#assign solutionCount = rest("/users/id/${messageAuthorId}/solutions/received/count").value />
    <#assign rankingName = rest("users/id/${messageAuthorId}/ranking/name").value />
    <#assign profileUrl = "/t5/user/viewprofilepage/user-id/${messageAuthorId}" />
    <#assign profileLocation = restadmin("/users/id/${messageAuthorId}/profiles/name/location").value />
    <#assign profileIP = restadmin("/users/id/${messageAuthorId}/settings/name/user.last_visit_ipaddress").value />
    <#if messageAuthorId?number &gt; 0>
    <#assign regDate = restadmin("/users/id/${messageAuthorId}/registration_time?restapi.response_style=view").value?datetime("yyyy-MM-dd'T'hh:mm:ss")?string("dd.MM.yyyy") />
    <#else>
    </#if>

     You already fetched the id during rest call so you do not need to use messageAuthorId.user.id, you just need to use messageAuthorId and need to convert that id into number as well to make it compatible with the right-hand side.