Hi,
When i open any account entry, then I get accountID using this script:
var accountId=Xrm.Page.data.entity.getId();
and i want related contacts bind in any textbox on the behalf of account.
*This post is locked for comments
Hi,
When i open any account entry, then I get accountID using this script:
var accountId=Xrm.Page.data.entity.getId();
and i want related contacts bind in any textbox on the behalf of account.
*This post is locked for comments
Hi ,
You can implement below code
var accountId = Xrm.Page.data.entity.getId();
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.0/contacts?$select=firstname,lastname,fullname&$filter=_accountid_value eq " + accountId + "", false);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("Prefer", "odata.maxpagesize=10");
req.onreadystatechange = function () {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 200)
{
var results = JSON.parse(this.response);
for (var i = 0; i < results.value.length; i++)
{
var firstnaem = results.value[i]["firstname"];
}
}
else
{
alert(this.statusText);
}
}
};
req.send();
}
Hi,
You can get it using quick view form as well.Please check below link:
community.dynamics.com/.../252551
Hope this helps:)
Hello,
Here is the code -
var accountId = Xrm.Page.data.entity.getId();
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.0/contacts?$select=firstname,lastname&$filter=_accountid_value eq " + accountId + "", false);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function () {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 200)
{
var results = JSON.parse(this.response);
for (var i = 0; i < results.value.length; i++)
{
var firstname = results.value[i]["firstname"];
}
}
else
{
//Error
}
}
};
req.send();
Hi,
please take a look - https://community.dynamics.com/crm/f/117/t/268428
I have shared the code for the similar requirement. Hope it helps
Mark this an answer, If it helps.
Cheers
Arpit
https://arpitmscrmhunt.blogspot.in
Hi,
You would need to write custom javascript code to retrieve the related contacs for that account using Web API.
refer this-
community.dynamics.com/.../ms-crm-2016-web-api-operations-retrieve-single-or-multiple-records
Hope this helps.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,214 Most Valuable Professional
nmaenpaa 101,156