Skip to main content
Navigate to microsoft.com
Power Pages
  • Capabilities
  • Pricing
    • Documentation
    • Blog
    • Support
    • Overview
    • Forums
    • Galleries
    • Ideas
    • User groups
  • Register
  • ·
  • Sign in
  • ·
  • Help
Go To
  • Microsoft Power Pages Community
  • Welcome to the Community!
  • News & Announcements
  • Get Help with Power Pages
  • General Discussions
  • Design & Build
  • Customize & Extend
  • Security
  • Administer & Monitor
  • Power Apps Portals
  • Galleries
  • Community Connections & How-To Videos
  • Webinars and Video Gallery
  • Front-end Code Samples
  • Portal-Friendly Code Component Samples
  • Portal Web API Services
  • Liquid Code Samples
  • Events
  • Community Blog
  • Power Pages Community Blog
  • Community Support
  • Community Accounts & Registration
  • Using the Community
  • Community Feedback
cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for 
Search instead for 
Did you mean: 
  • Microsoft Power Pages Community
  • Forums
  • Get Help with Power Pages
  • Power Apps Portals
  • Re: Liquid error : Show Account/contact Entity Ima...
Reply
Topic Options
  • Subscribe to RSS Feed
  • Mark Topic as New
  • Mark Topic as Read
  • Float this Topic for Current User
  • Bookmark
  • Subscribe
  • Printer Friendly Page
  • All forum topics
  • Previous Topic
  • Next Topic
GrazielyLarios
GrazielyLarios
Regular Visitor
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

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

‎11-25-2019 08:44 AM

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.

 
But, if I try to show another entity image (e.g. products) I have success.
My entity permissions is running well and if I remove the entityimage attribute from fetch my query run and show data normally.
 
 
 

 

{% 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 %}

 

Preview file
71 KB
Preview file
129 KB
Message 1 of 5
1,971 Views
0 Kudos
Reply
  • All forum topics
  • Previous Topic
  • Next Topic
4 REPLIES 4
v-xida-msft
Community Support v-xida-msft
Community Support
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

‎11-25-2019 10:35 PM

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Message 2 of 5
1,956 Views
0 Kudos
Reply
GrazielyLarios
GrazielyLarios
Regular Visitor
In response to v-xida-msft
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

‎11-26-2019 02:22 AM

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

Message 3 of 5
1,949 Views
0 Kudos
Reply
Django
Django
MVP
In response to GrazielyLarios
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

‎03-16-2020 05:45 AM

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-p... 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 👍

Message 4 of 5
1,731 Views
1 Kudo
Reply
Anonymous
Not applicable
In response to GrazielyLarios
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

‎04-28-2020 03:07 PM

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. 

Message 5 of 5
1,698 Views
0 Kudos
Reply

Helpful resources

Announcements
Carousel Community Blog

Check out the Community Blog

Read all about the most recent blogs in the community!

Visit Now
Carousel News & Announcements

What's New in the Community?

Check out the latest News & Events in the community!

Visit Now
spinner
View All
Top Kudoed Authors
User Count
OliverRodrigues
Super User OliverRodrigues
3
Cosmic_Kitchen
Cosmic_Kitchen
1
kadro
kadro
1
ragavanrajan
Super User ragavanrajan
1
MichaelGartner
MichaelGartner
1
View All
Users online (3,314)
  • LukaszSl
  • Ramole
  • Django
  • jukka-niiranen
  • GuidoPreite

Power Platform

  • Overview
  • Power BI
  • Power Apps
  • Power Pages
  • Power Automate
  • Power Virtual Agents

Resources

  • Documentation
  • Blog
  • Support
  • Community

  • © 2023 Microsoft
  • Privacy & cookies
  • Terms of use
  • Trademarks
California Consumer Privacy Act (CCPA) Opt-Out Icon Your California Privacy Choices