Hi waleed,
You can write javascript for the above and call the function on change of project field.
function onChangeOfProject(){
var projectId;
var project = Xrm.Page.data.entity.attributes.get("project");
projectId=this.GetLookupID(project);
if(projectId==null){
return;
}
var encodedFetchXML=this.getFetchXml(projectId);
var units=this.GetUnitDetails(encodedFetchXML);
}
function getFetchXml(projectId){
var fetchXML = ['<fetch distinct="false" mapping="logical" output-format="xml-platform" version="1.0">'+
'<entity name="project">'+
'<attribute name="country"/>'+
'<filter type="and">'+
'<condition attribute="projectid" value="'+projectId+'" operator="eq"/>'+
'</filter>'+
'</entity>'+
'</fetch>'].join('');
var encodedFetchXML = encodeURIComponent(unitFetchXML);
return encodedFetchXML;
}
function setCountry(encodedFetchXML){
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.0/productpricelevels?fetchXml=" + encodedFetchXML, true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Prefer", "odata.include-annotations=\"OData.Community.Display.V1.FormattedValue\"");
req.onreadystatechange=function(){
if (req.readyState === 4){
req.onreadystatechange = null;
if (req.status === 200){
var results = JSON.parse(this.response);
if(results.value.length==1)
{
var unitDetails=results.value[0];
var country=unitDetails['country'];
Xrm.Page.getAttribute("cld_amount").setValue(country);
}
}
}
};
req.send();
}
The above script is not accurate, you need to make the changes as per your entity and attribute names