Myko_P
8 years agoExpert
InvalidReferenceException Error in the Studio's Custom component
Hi,
I got custom authors component from the predesessors wich started to show followin error message in the Studio - Components - Preview interface:
Freemarker template 'preview' processing failed: InvalidReferenceException:The following has evaluated to null or missing: ==> env.context.message [in template "preview" at line 1, column 6]
What can I do fix the error? Code of the custom component:
<#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 /> <#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") /> <#assign loginBoldness = restadmin("/users/id/${messageAuthorId}/ranking/display/bold").value?boolean /> <#assign loginColor = restadmin("/users/id/${messageAuthorId}/ranking/display/color").value /> <#assign loginColorClass = "color: #"+loginColor /> <#attempt> <#assign checkLeftIcon = restadmin("/users/id/${messageAuthorId}/ranking/display/left_image/url")> <#assign leftIcon = restadmin("/users/id/${messageAuthorId}/ranking/display/left_image/url").value > <#recover><#assign leftIcon = ""></#attempt> <#attempt> <#assign checkLightIcon =restadmin("/users/id/${messageAuthorId}/ranking/display/right_image/url")> <#assign rightIcon = restadmin("/users/id/${messageAuthorId}/ranking/display/right_image/url").value > <#recover><#assign rightIcon = ""></#attempt> <style> ul.badges_mini li a img { height: 30px; float: left; } table.stat_width { width: 98%; } td.stat_align { text-align: right; } </style> <#if settings.name.get("profile.language") == "uk" > <div class="lia-message-author lia-component-author"> <div class="lia-message-author-username"> <span class="UserName lia-user-name lia-user-rank------"> <#if leftIcon?has_content> <img class="lia-user-rank-icon lia-user-rank-icon-left" title="${rankingName}" alt="${rankingName}" id="display_15" src="${leftIcon}"> <#else> </#if> <a class="lia-link-navigation lia-page-link lia-user-name-link" style="${loginColorClass}" target="_self" id="link_18" href="${profileUrl}"> <#if loginBoldness == true> <span><b>${messageAuthorLogin}</b></span> <#else> <span>${messageAuthorLogin}</span> </#if> </a> <#if rightIcon?has_content> <img class="lia-user-rank-icon lia-user-rank-icon-right" title="${rankingName}" alt="${rankingName}" id="display_10" src="${rightIcon}"> <#else> </#if> </span> </div> <div class="lia-message-author-rank"> ${rankingName} </div> <div class="lia-message-author-avatar"> <div class="UserAvatar lia-user-avatar lia-component-common-widget-user-avatar"> <a class="UserAvatar lia-link-navigation" tabindex="-1" target="_self" id="link_1_4" href="${profileUrl}"> <img class="lia-user-avatar-message" title="${rankingName}" alt="${rankingName}" id="display_5" src="${avatarUrl}"> </a> </div> </div> <div class="lia-message-author-post-count"> <table class="stat_width"><tr><td>Повідомлень:</td><td class="stat_align">${postCount}</td></tr></table> </div> <div class="lia-message-author-kudos-count"> <table class="stat_width"><tr><td>ДЯКів:</td><td class="stat_align">${kudosCount}</td></tr></table> </div> <div class="lia-message-author-solution-count"> <table class="stat_width"><tr><td>Рішень:</td><td class="stat_align">${solutionCount}</td></tr></table> </div> <div class="lia-message-author-kudos-count"> <table class="stat_width"><tr><td>Повідомлень у блогах:</td><td class="stat_align">${blogCount}</td></tr></table> </div> <div class="lia-message-author-badges"> <table class="stat_width"><tr><td>Бейджів:</td><td style="text-align:right;"><a href="/t5/badges/userbadgespage/user-id/${messageAuthorId}/page/1" style="font-size: 13px;" title="Переглянути всі">${badgesCount}</a></td></tr></table> <ul class="badges_mini"> <#attempt> <#if badges?has_content> <#attempt> <#attempt> <#list 0..5 as i> <#if (badges.user_badges.user_badge[i]??)> <li><a href="/t5/badges/userbadgespage/user-id/${messageAuthorId}/page/1" title="${badges.user_badges.user_badge[i].badge.title}"><img src="${badges.user_badges.user_badge[i].badge.icon_url}" title="${badges.user_badges.user_badge[i].badge.title}" /></a></li> </#if> </#list> <#recover> badge loops failed </#attempt> <#recover> badge logic failed </#attempt> <#else> <li class="noBadges">Не має бейджів :(</li> </#if> <#recover> badge query failed </#attempt> </ul> </div> <div style="clear: both;"></div> <div class="lia-message-author-location"> <#if profileLocation!?length != 0> <table class="stat_width"><tr><td>Місто:</td><td class="stat_align">${profileLocation}</td></tr></table> <#else> </#if> </div> <div class="lia-message-author-registered-date"> <table class="stat_width"><tr><td>В клубі з</td><td class="stat_align">${regDate}</td></tr></table> </div> <#if user.registered > <#list restadmin("/authentication/sessions/current/user/roles").roles.role as role> <#if role.name?? && ((role.name == "Administrator") || (role.name == "Analytics") || (role.name == "Moderator") || (role.name == "Lithium"))> <div class="lia-message-author-ipaddress"> <table class="stat_width"><tr><td>IP-адреса:</td><td class="stat_align">${profileIP}</td></tr></table> </div> </#if> </#list> <div> <span class="send-msg"></br> <img src="/html/assets/mail.png" style="top:2px;" /> <a href="/t5/notes/privatenotespage/tab/compose/note-to-user-id/${messageAuthorId}" style="font-size: 13px;" title="Надіслати приватне повідомлення">Надіслати ПП</a> </span> </div> </#if> </div> <#else> <div class="lia-message-author lia-component-author"> <div class="lia-message-author-username"> <span class="UserName lia-user-name lia-user-rank------"> <#if leftIcon?has_content> <img class="lia-user-rank-icon lia-user-rank-icon-left" title="${rankingName}" alt="${rankingName}" id="display_15" src="${leftIcon}"> <#else> </#if> <a class="lia-link-navigation lia-page-link lia-user-name-link" style="${loginColorClass}" target="_self" id="link_18" href="${profileUrl}"> <#if loginBoldness == true> <span><b>${messageAuthorLogin}</b></span> <#else> <span>${messageAuthorLogin}</span> </#if> </a> <#if rightIcon?has_content> <img class="lia-user-rank-icon lia-user-rank-icon-right" title="${rankingName}" alt="${rankingName}" id="display_10" src="${rightIcon}"> <#else> </#if> </span> </div> <div class="lia-message-author-rank"> ${rankingName} </div> <div class="lia-message-author-avatar"> <div class="UserAvatar lia-user-avatar lia-component-common-widget-user-avatar"> <a class="UserAvatar lia-link-navigation" tabindex="-1" target="_self" id="link_1_4" href="${profileUrl}"> <img class="lia-user-avatar-message" title="${rankingName}" alt="${rankingName}" id="display_5" src="${avatarUrl}"> </a> </div> </div> <div class="lia-message-author-post-count"> <table class="stat_width"><tr><td>Сообщений:</td><td class="stat_align">${postCount}</td></tr></table> </div> <div class="lia-message-author-kudos-count"> <table class="stat_width"><tr><td>ДЯКов:</td><td class="stat_align">${kudosCount}</td></tr></table> </div> <div class="lia-message-author-solution-count"> <table class="stat_width"><tr><td>Решений:</td><td class="stat_align">${solutionCount}</td></tr></table> </div> <div class="lia-message-author-kudos-count"> <table class="stat_width"><tr><td>Сообщений в блогах:</td><td class="stat_align">${blogCount}</td></tr></table> </div> <div class="lia-message-author-badges"> <table class="stat_width"><tr><td>Бейджей:</td><td class="stat_align"><a href="/t5/badges/userbadgespage/user-id/${messageAuthorId}/page/1" style="font-size: 13px;" title="Посмотреть все">${badgesCount}</a></td></tr></table> <ul class="badges_mini clearboth"> <#attempt> <#if badges?has_content> <#attempt> <#attempt> <#list 0..5 as i> <#if (badges.user_badges.user_badge[i]??)> <li><a href="/t5/badges/userbadgespage/user-id/${messageAuthorId}/page/1" title="${badges.user_badges.user_badge[i].badge.title}"><img src="${badges.user_badges.user_badge[i].badge.icon_url}" title="${badges.user_badges.user_badge[i].badge.title}" /></a></li> </#if> </#list> <#recover> badge loops failed </#attempt> <#recover> badge logic failed </#attempt> <#else> <li class="noBadges">Нет бейджей</li> </#if> <#recover> badge query failed </#attempt> </ul> </div> <div style="clear: both;"></div> <div class="lia-message-author-location"> <#if profileLocation!?length != 0><table class="stat_width"><tr><td>Город:</td><td class="stat_align">${profileLocation}</td></tr></table><#else></#if> </div> <div class="lia-message-author-registered-date"> <table class="stat_width"><tr><td>В Клубе с</td><td class="stat_align">${regDate}</td></tr></table> </div> <#if user.registered > <#list restadmin("/authentication/sessions/current/user/roles").roles.role as role> <#if role.name?? && ((role.name == "Administrator") || (role.name == "Analytics") || (role.name == "Moderator") || (role.name == "Lithium"))> <div class="lia-message-author-ipaddress"> <span class="UserIpAddress"> <table class="stat_width"><tr><td>IP-адрес:</td><td class="stat_align">${profileIP}</td></tr></table> </span> </div> </#if> </#list> <div> <span class="send-msg"></br> <img src="/html/assets/mail.png" style="top:2px;"/> <a href="/t5/notes/privatenotespage/tab/compose/note-to-user-id/${messageAuthorId}" style="font-size: 13px;" title="Отправить личное сообщение">Отправить ЛС</a> </span> </div> </#if> </div> </#if> <#else> </#if>
env variables work respective to page. This variable is not for studio. It will work on forum topic page without any error. Please include this component in forum topic page or forum message page.