
Announcements
I have created one advance form in the power portal and in the first step of the form i'm trying to get the Contact information of the current user from Contacts entity.
For this I have written the below javascript code under from definition section to get the data.
$(document).ready(function(){var fetchXmlQuery = `
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="contact">
<attribute name="fullname" />
<attribute name="cr0d4_companyname" />
<attribute name="contactid" />
<attribute name="description" />
<attribute name="websiteurl" />
<order attribute="fullname" descending="false" />
<filter type="and">
<condition attribute="statecode" operator="eq" value="0" />
<condition attribute="fullname" operator="eq" value="{{ user.fullname }}" />
</filter>
</entity>
</fetch>`;
var req = new XMLHttpRequest();
req.open("GET", "https://Sample.crm5.dynamics.com/api/data/v9.0/cr0d4_incidentreports?fetchXml=" +
encodeURIComponent(fetchXmlQuery), true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function ()
{
if (this.readyState === 4)
{
this.onreadystatechange = null;
if (this.status === 200)
{
var returned = JSON.parse(this.responseText);
alert(returned);
}
else
{
alert(this.status);
}
}
};
req.send();
});
Note I have created the permission for entity and added the web role and i can see the data while accessing request URL on the browser.
Hi @Hiral2010
Probably related to API permissions for the portal sitting in Azure App registrations. Please have a look at the following thread.
Hope it helps.
------------
If you like this post, give it a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users to find it.