My entity permissions is running well and if I remove the entityimage attribute from fetch my query run and show data normally.
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:image/jpeg;base64,' + base64data;
}
});
});
</script>
{% endfor %}
{% endif %}
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: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,
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
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 👍
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.
User | Count |
---|---|
3 | |
1 | |
1 | |
1 | |
1 |