Reputation: 634
I am trying to append values to an HTML web resource in Microsoft Dynamics CRM 2011. I am using the REST service to get values of related objects to my current form and would like to display them in html.
Currently I have set up an HTML web resource with a table but cannot seem to update the rows.
Given this code:
alert(document.getElementById('WebResource_consultdetails').innerHTML);
document.getElementById('WebResource_consultdetails').innerHTML = "DETAILS ARE HERE";
alert(document.getElementById('WebResource_consultdetails').innerHTML);
...the first alert is blank, and the second alert has the proper html, however the changes are never displayed on the form.
Am I missing a step?
Upvotes: 0
Views: 2319
Reputation: 553
I've affected an HTML Web Resource in a slightly different manner.
Rather than having the logic running in the CRM form and trying to affect the web resource, turn it around and have an event on the CRM form call a method in the web resource. Here's an example I've ripped out of a working system.
function prodformOnLoad() {
switch (Xrm.Page.ui.getFormType()) {
case (1):
case (5):
case (6):
// do nowt
break;
default:
// everything else
Xrm.Page.data.entity.attributes.get("productid").fireOnChange();
}
}
function productOnChange() {
Xrm.Page.getControl("WebResource_Costs").getObject().contentWindow.window.refreshTable();
}
The refreshTable()
method on the web resource has all the logic in there, gleaning its information from window.parent.Xrm.yadda.yadda
Upvotes: 2
Reputation: 617
Get the values of related objects, you need to do it inside html webresource. You can use OData query to retrieve the value.
After you get the values, assign to your html element, also do it inside html webresource.
For example: The value you got is: "VALUE";
There must be an element in your html webresource - something like: <td id="myid"></td>
;
And then assign value like this:
document.getElementById("myid").innerHTML = "VALUE";
Upvotes: 1