Hello everyone!
I 'm trying to this without using plugins and i can't make it. It can be done using workflow but i want to run real time when the lookup field changes value.
So here is my entity form:

I have added a Quick View Form at the bottom.
I've tried with unsupported way to do it using this code:
function getQuickValue() {
setTimeout(setValue,2000);
}
function setValue() {
var productQuickViewcost = document.getElementById("QuickViewProduct_QuickViewProduct_ral_product_ral_cost_d").getAttribute("title");
alert(productQuickViewcost);
Xrm.Page.getAttribute("ral_cost").setValue(productQuickViewcost);
Xrm.Page.getAttribute("ral_cost").setSubmitMode("always");
}
It doesn't work but it could work after some tweaking because using console the alert displays correctly the cost in quick view form . However i want to do this with a supported way so i found this url which uses REST Endpoint to do it.
https://blogs.msdn.microsoft.com/emeadcrmsupport/2015/09/24/dynamics-crm-how-to-access-a-quickform-component-via-jscript-in-turbo-forms/
I have tried this code :
function getCost() {
var product = Xrm.Page.data.entity.attributes.get("ral_product").getValue()[0];
alert("productid =" + product.id);
retrieveCost(product.id);
}
function retrieveCost(productId) {
SDK.REST.retrieveRecord(
productId,
"Product",
null, null,
function (ral_product)
{
testFunction(ral_product);
},
function () {
alert("Error Occured.");
}
);
}
function testFunction(ral_product) {
alert(ral_product.ral_cost);
}
Where "Product" is the display name of my custom entity and ral_product is the internal name. When running it i get "Error Occured". Any ideas what i did wrong?
Thanks!
*This post is locked for comments
I have the same question (0)