web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Liquid error : Show Ac...
Power Pages
Unanswered

Liquid error : Show Account/contact Entity Image on portals not working

(0) ShareShare
ReportReport
Posted on by 3

Hi all, 

I'm trying to show account or contact entity image on portals but when I try to run I receive an error message : 

Liquid error: Exception has been thrown by the target of an invocation.

 

 

{% fetchxml contact_account_query %}
<fetch version="1.0" mapping="logical">
 <entity name="contact">
 <all-attributes />
 <filter type="and">
 <condition attribute="contactid" operator="eq" value="{{ user.id }}">
 </condition>
 </filter>
 <link-entity name="account" from="accountid" to="parentcustomerid" visible="false" alias="ai">
 <attribute name="name" />
 <attribute name="entityimage" />
 <attribute name="entityimage_url" />
 </link-entity>
 </entity>
</fetch>
{% endfetchxml %}
{% if contact_account_query.results.entities.size > 0 %}
{% for result in contact_account_query.results.entities %}
<br>Contact Name : {{result.fullname}}
<br>Account Name : {{result['ai.name']}}
<img data-entityimage="{{result['ai.entityimage'] | join: ',' }}" />
<script type="text/javascript">
 function toBase64(str) {
 if (!str) return null;
 var uarr = new Uint8Array(str.split(',').map(function(x) {
 return parseInt(x);
 }));
 return btoa(String.fromCharCode.apply(null, uarr));
 }
 // Find any entity images and convert the byte string to base64
 window.addEventListener('load', function() {
 document.querySelectorAll('img[data-entityimage]').forEach(function(img) {
 var data = img.dataset && img.dataset.entityimage;
 var base64data = data ? toBase64(data) : null;
 if (base64data) {
 img.src='data&colon;image/jpeg;base64,' + base64data;
 }
 });
 });
</script>
{% endfor %}
{% endif %}

 

liquid return.PNG
powerApp.PNG
Categories:
I have the same question (0)
  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @GrazielyLarios ,

    Have you enabled "Entity Permission" option for the Contact Entity within your Portal?

    Which security role do you have within current Environment?

     

    Based on the code that you mentioned, I found that you specified entityimage_url attribute within the <link-entity> tag. Please make sure the entityimage_url field are existed in your Account Entity already. If the entityimage_urlfield is not existed in your Account Entity, please consider remove it from your <link-entity>tag.

    {% fetchxml contact_account_query %}
    <fetch version="1.0" mapping="logical">
     <entity name="contact">
     <all-attributes />
     <filter type="and">
     <condition attribute="contactid" operator="eq" value="{{ user.id }}">
     </condition>
     </filter>
     <link-entity name="account" from="accountid" to="parentcustomerid" visible="false" alias="ai">
     <attribute name="name" />
     <attribute name="entityimage" />
     </link-entity>
     </entity>
    </fetch>
    {% endfetchxml %}
    {% if contact_account_query.results.entities.size > 0 %}
    {% for result in contact_account_query.results.entities %}
    <br>Contact Name : {{result.fullname}}
    <br>Account Name : {{result['ai.name']}}
    <img data-entityimage="{{result['ai.entityimage'] | join: ',' }}" />
    <script type="text/javascript">
     function toBase64(str) {
     if (!str) return null;
     var uarr = new Uint8Array(str.split(',').map(function(x) {
     return parseInt(x);
     }));
     return btoa(String.fromCharCode.apply(null, uarr));
     }
     // Find any entity images and convert the byte string to base64
     window.addEventListener('load', function() {
     document.querySelectorAll('img[data-entityimage]').forEach(function(img) {
     var data = img.dataset && img.dataset.entityimage;
     var base64data = data ? toBase64(data) : null;
     if (base64data) {
     img.src='data&colon;image/jpeg;base64,' + base64data;
     }
     });
     });
    </script>
    {% endfor %}
    {% endif %}

     

    In addition, please also check if you have enabled "Entity Permission" option for the Contact Entity within your Portal, if true, please consider sign in your Portal, then try it again, check if the issue is solved.

     

    Also please check if you have been assigned with proper Security Role within current Environment.

     

    Best regards,

  • Graziely Larios Profile Picture
    3 on at

    Hi, 

    Thanks for your reply. 

     

    I review all entity permissions and if I remove entity image attributes I can show customer data normally on portals (is there an entity permission to see just the image from specifically entity?), because all another contact/account data is running good.

     

    I still tried to show contact image using fetch to get user (contacid = {{user.id}}) and dont use  link-entity but this didn't work too. 

     

    *Before testing all changes I'm doing I clearing cache to don't have any delay problem

  • m3ngi3 Profile Picture
    725 on at

    As a simple end-user, the profile picture that links to nothing also puzzled me...

    Referring this post: https://community.dynamics.com/crm/b/thinkdynamicdodynamic/posts/how-to-set-profile-picture-in-crm-portal the linked entities are Web Files / Notes also need to be configured?

    I hope this post will help or if you have solved it another way please share 👍

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I encountered exactly the same issue. I was trying to show the icon image of the current portal user (contact). However, once I granted Global access (entity permission) of the contact entity to the portal user, I was able to query the entityimage field. The other types of permission, such as Self, Account, and Parent do not work for me. I do not why, it could be a bug, but it seems the entityimage field is only available through Global access permission for now. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
Valantis Profile Picture

Valantis 65

#2
11manish Profile Picture

11manish 55

#3
Vish WR Profile Picture

Vish WR 29

Last 30 days Overall leaderboard