1. Select the entity and the filter criteria based on your business requirements.
2. Click Generate
3. Now we going to create a web resources (JS),passing the value dynamically.
function Odata()
{
//Get Opportunity Id
var formType = Xrm.Page.ui.getFormType();
Master= Xrm.Page.getAttribute("crmfieldschemaname").getValue();
var guid = Master[0].id;
OdataCode(guid);
}
function OdataCode(guid)
{
var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";
crmServerUrl = Xrm.Page.context.getServerUrl();
var oDataUri =crmServerUrl+ODATA_ENDPOINT+"replace your code here"; jQuery.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: oDataUri,
beforeSend: function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader("Accept", "application/json"); },
success: function (data, textStatus, XmlHttpRequest)
{
// Use only one of these two methods
// Use for a selection that may return multiple entities
ProcessReturnedEntities(data.d.results);
},
error: function (XmlHttpRequest, textStatus, errorThrown) { alert("Ajax call failed: " + textStatus + " - " + errorThrown + " || " + XmlHttpRequest.responseText);}
});
}
function ProcessReturnedEntities(ManyEntities)
{
var grandTotal = 0;
for(var i=0; i< ManyEntities.length; i++)
{
var oneEntity = ManyEntities[i];
var totalPriceAttribute = oneEntity."the field that you want to select";
}
}
4. thing to remember when you replace the filter value dynamically.
crmServerUrl = Xrm.Page.context.getServerUrl();
var oDataUri =crmServerUrl+ODATA_ENDPOINT+"/new_petitionSet?$filter=new_CurrentMasterName/Id eq guid'"{remember to have a space here}+guid+"' and new_PetitionStatus/Id eq guid'50992E47-5518-E311-9CC8-005056A64D95'";
No comments:
Post a Comment