I need all the contacts belongs to a particular account .Is there any way to pull contacts in CRM webapi ?
*This post is locked for comments
I need all the contacts belongs to a particular account .Is there any way to pull contacts in CRM webapi ?
*This post is locked for comments
function retireveContacts() { var accountId = Xrm.Page.getAttribute('<acconut lookup schema name>').getValue(); var req = new XMLHttpRequest(); req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.0/contacts?$select=firstname,lastname,_ownerid_value&$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.include-annotations=\"OData.Community.Display.V1.FormattedValue\""); 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 firstname = results.value[i]["firstname"]; var lastname = results.value[i]["lastname"]; var _ownerid_value = results.value[i]["_ownerid_value"]; var _ownerid_value_formatted = results.value[i]["_ownerid_value@OData.Community.Display.V1.FormattedValue"]; } } else { alert(this.statusText); } } }; req.send(); }
Firstly, what is the lookup name for account. I dont think it is parentcustomerid. Whatever it is , replace in belo code and then try
Hi,
isn't it the same question you were asking yesterday? What did not work?
Hi Joy,
You could use the following URL in web API to get all the contacts belonging to a particular account.
"yourinstancename.api.crmx.dynamics.com/.../contacts eq " + YourGuid
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