Hi,
Today we got a requirement to show Product Properties related to Opportunity Product in a HTML Webresource.
Here is the JavaScript code to read Product Properties.
var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";
var retrieveRecordsReq = new XMLHttpRequest();
var oDataPath = "";
var entityName = "DynamicPropertyInstance";
var entityNameField = "*";
oDataPath = Xrm.Page.context.getClientUrl() + ODATA_ENDPOINT + "/" + entityName + "Set?$select=*&$filter=RegardingObjectId/Id eq guid'" + vOpportunityProductId + "'";
retrieveRecordsReq.open('GET', oDataPath, false);
retrieveRecordsReq.setRequestHeader("Accept", "application/json");
retrieveRecordsReq.setRequestHeader("Content-Type", "application/json; charset=utf-8")
retrieveRecordsReq.send(null);
var retrievedData = JSON.parse(retrieveRecordsReq.responseText).d;
if (retrievedData != null && retrievedData != undefined && retrievedData.results != null) {
jsonResult = retrievedData.results;
}
return jsonResult;
}
Hope this helps.
--
Happy CRM'ing
Today we got a requirement to show Product Properties related to Opportunity Product in a HTML Webresource.
Here is the JavaScript code to read Product Properties.
function getProperties() {
var jsonResult = null;var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";
var retrieveRecordsReq = new XMLHttpRequest();
var oDataPath = "";
var entityName = "DynamicPropertyInstance";
var entityNameField = "*";
oDataPath = Xrm.Page.context.getClientUrl() + ODATA_ENDPOINT + "/" + entityName + "Set?$select=*&$filter=RegardingObjectId/Id eq guid'" + vOpportunityProductId + "'";
retrieveRecordsReq.open('GET', oDataPath, false);
retrieveRecordsReq.setRequestHeader("Accept", "application/json");
retrieveRecordsReq.setRequestHeader("Content-Type", "application/json; charset=utf-8")
retrieveRecordsReq.send(null);
var retrievedData = JSON.parse(retrieveRecordsReq.responseText).d;
if (retrievedData != null && retrievedData != undefined && retrievedData.results != null) {
jsonResult = retrievedData.results;
}
return jsonResult;
}
Hope this helps.
--
Happy CRM'ing
Gopinath
this will only give you the values of the properties , the name field is null, it is in dynamicproperty entity, how to get both ? i tried retrieveproductproperties function but cannot get value
ReplyDelete