Reputation: 21
Currently when replying to an e-mail the description content is loaded before my JavaScript runs.
Is there a way to wait for the description to load, before JavaScript code is executed?
My code:
function test() {
var desc = xrm.Page.getAttribute("description").getValue();
alert(desc); //Nothing, since description loads after I get the value
}
I added this function to the on load event of my form.
Thanks for your time.
Upvotes: 1
Views: 391
Reputation: 21
I solved the problem by checking if description is empty, and if it is, rerun the function.
function test() {
if (Xrm.Page.getAttribute("description").getValue() == "") {
console.log("Description empty, rerunning in 1 second");
setTimeout(function() {
test();
}, 1000);
} else {
console.log(Xrm.Page.getAttribute("description").getValue());
}
}
Upvotes: 1
Reputation: 392
According to this blog post you have to wait for the description to load fully. Just in the same way you have to wait for a subgrid to load before accessing it.
Upvotes: 3