JScript: Retrieving Opportunities Related to Contact Entity Using ODATA

Microsoft Dynamics CRM is a Customer Relationship Management software package developed by Microsoft
Post Reply
User avatar
gellee
Posts: 46
Joined: Fri Jan 20, 2012 3:04 pm

JScript: Retrieving Opportunities Related to Contact Entity Using ODATA

Post by gellee »

1. Import sdk.jquery.js and Json2.js library from CRM SDK
2. Add sdk.jquery.js and Json2.js to form library
3. Call the JScript below



function retrieveRelatedRecord() {

var id = Xrm.Page.data.entity.getId();

SDK.JQuery.retrieveMultipleRecords(
"opportunity",
"$select=name&$filter=customerId/Id eq (guid'" + id + "')",
function (results) {
var firstResult = results[0];
if (firstResult != null) {
for (var i = 0; i < results.length; i++) {
alert(results.name);
}

}
else {
alert("No Contact records are available to set as the primary contact for the account.");
}
},
errorHandler,
function () {
//OnComplete handler
}
);

}


function errorHandler() {
//do nothing
}
xaeresis
Posts: 196117
Joined: Wed Oct 04, 2023 2:39 pm

Re: JScript: Retrieving Opportunities Related to Contact Entity Using ODATA

Post by xaeresis »

xaeresis
Posts: 196117
Joined: Wed Oct 04, 2023 2:39 pm

Re: JScript: Retrieving Opportunities Related to Contact Entity Using ODATA

Post by xaeresis »

Post Reply