For example account has 4 contacts, out of which I need to retrieve contact id of a contact which has phone number
*This post is locked for comments
Use CRM Rest Builder for creating Rest data queries.
Refer below code
var contacts = $.ajax({ type: "GET", contentType: "application/json; charset=utf-8", datatype: "json", url: Xrm.Page.context.getClientUrl() + "/api/data/v8.2/contacts?$select=contactid&$filter=_accountid_value eq 6d5f2230-8091-4fbf-9cbf-ae9f712c8a79 and mobilephone ne null", beforeSend: function(XMLHttpRequest) { XMLHttpRequest.setRequestHeader("OData-MaxVersion", "4.0"); XMLHttpRequest.setRequestHeader("OData-Version", "4.0"); XMLHttpRequest.setRequestHeader("Accept", "application/json"); XMLHttpRequest.setRequestHeader("Prefer", "odata.include-annotations=\"*\""); }, async: true, success: function(data, textStatus, xhr) { var results = data; for (var i = 0; i < results.value.length; i++) { var contactid = results.value[i]["contactid"]; } }, error: function(xhr, textStatus, errorThrown) { Xrm.Utility.alertDialog(textStatus + " " + errorThrown); } });
Or you can create fech xml to build above query and concat you paramaters for query in fetch xml
and put in below field (Check screnshot)
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,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156