Hey guys,
I'm trying to get a TinyMCE rich text editor as a popup in my email form (the Alexander Development.net solution) working. Unfortunately I'm having trouble with catching the value of the email description (/body) into a variable this way:
var emailBody = parent.frames[0].Xrm.Page.getAttribute("description").getValue();
It returns this nice "Cannot read property 'Page' of undefined" error, while I was pretty sure this was the 2016 way of getting it done.
Since I'm not much of a javascript developer (obviously), I'm kind of stuck.
Anybody got a better idea or anyone knows how to get the description into the variable? It's building even before the popup is called, so I figured 'parent' would do the job (being the parent of the html web resource).. but clearly I'm wrong.
Any ideas?
thanks in advance!
Regards,
Jeroen
*This post is locked for comments
Hey David,
thanks for your quick reply! It worked as a charm!
I think your problem is that there may be several frames within the parent object, whereas your code assumes that the email description is in the first one (frames[0]). Instead, try looping through each frame in turn, like below:
var emailBody; for (var i=0;i<parent.frames.length;i++) { if (parent.frames[i].Xrm != null && parent.frames[i].Xrm.Page != null) { var ctl = parent.frames[i].Xrm.Page.getAttribute("description"); if (ctl != null) { emailBody = ctl.getValue(); break; } } }
Mohamed Amine Mahmoudi
83
Super User 2025 Season 1
Community Member
54
Victor Onyebuchi
6