Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 9244

Retrieving pricelist entity data in crm 2013 using odata

$
0
0

Hi,

       I am using crm 2013, i have two entities Quote and PriceList. In quote i have two fields. 'product' and 'product amount'. Product is a lookup filed and it is pointing to PriceList entity. 'product amount' is currency field. When i select a product in lookup field, we need to get the price of that product from pricelist entity and need to be update in the 'product amount' field of Quote entity.

for this i am using the below code.

 

function retrieverecord() {
alert('retrieverecord start');
  if (Xrm.Page.getAttribute("pricelevelid").getValue() != null) 
  {
     var pricelevelID = Xrm.Page.getAttribute("pricelevelid").getValue()[0].id;
     alert(pricelevelID);
var pname=document.getElementById("pricelevelid").innerText;
alert('hi '+pname);

var amount;
var serverUrl = window.parent.Xrm.Page.context.getClientUrl();
var oDataSelect = serverUrl + "/XRMServices/2011/OrganizationData.svc/AccountSet?$select=telephone2&$filter=name eq 'test'";
var retrieveReq = new XMLHttpRequest();
retrieveReq.open("GET", oDataSelect, false);
retrieveReq.setRequestHeader("Accept", "application/json");

retrieveReq.setRequestHeader("Content-Type", "application/json;charset=utf-8");
retrieveReq.onreadystatechange = function () {

if (retrieveReq.readyState == 4){

var retrieved = parent.JSON.parse(retrieveReq.responseText).d;

if (retrieved != null) {
alert('not null');
//productrange= productrange+ retrieved.results[0].new_ProductRange_value;

amount=retrieved.results.new_amount;
}
}
//GetProductData(this);
};
retrieveReq.send();
alert('Amount is:'+amount);
Xrm.Page.getAttribute("new_amount").setValue(amount);
}
}

But i am not getting the Product amount into quote entity.

Please help me if anyone have any idea on this.


Nagaraj


Viewing all articles
Browse latest Browse all 9244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>