Worked it out with javascript will create some prettier methods but did the job.
if (TestPrice === undefined)
{
var TestPrice = {};
}
// Get GUID of lookup field
var lookupObject = Xrm.Page.getAttribute("new_model");
if (lookupObject != null)
{
var lookUpObjectValue = lookupObject.getValue();
if ((lookUpObjectValue != null))
{
var lookupid = lookUpObjectValue[0].id;
}
}
MyNamespace.Machinery_OnLoad = function ()
{
// Create the calling URL string
var oDataURI = Xrm.Page.context.getClientUrl()
+ "/XRMServices/2011/OrganizationData.svc/"
+ "ProductPriceLevelSet"
+ "?$select="
+ "Amount"
+ "&$filter=ProductId/Id eq (guid'"
+ lookupid
+ "')";
var req = new XMLHttpRequest();
req.open("GET", encodeURI(oDataURI), true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function () {
//debugger;
if (this.readyState == 4 /* complete */)
{
req.onreadystatechange = null; //avoids memory leaks
if (this.status == 200)
{
//parse the response string as a JSON object.
var t = JSON.parse(this.responseText).d;
var amount = t.results[0].Amount.Value;
alert(amount);
}
else
{
alert(this.responseText);
}
}
}
req.send();
}