Answered by:
CRM 2011: call html webresource from jscript web resource

Question
-
Hi
I have a javascript running on the onload of an entity. Can I call a html webresource from this javascript? How?
If that html webresource returns some data, how can I show that data in the attributes of the entity form?
Any help will be highly appreciated.
Regards
Tuesday, June 19, 2012 1:47 PM
Answers
-
That's what the first line of the code I posted is doing.
var suburb = window.showModalDialog("http://tcrm2010:5555/CRM/WebResources/new_SuburbOption?data=" + param, false, 'dialogHeight:400px;dialogWidth:200px');
In the above line, I m opening a modal dialog webresource named new_SuburbOption and passing a data parameter to it.
then i am returning the value from the resource using window.returnValue.
I hope this helps.
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Amreek Singh Senior CRM Consultant CDC Praxa Sydney, Australia http://mscrmshop.blogspot.com http://crm2011usersettings.codeplex.com
- Marked as answer by Karan Mittal Wednesday, June 20, 2012 1:25 PM
Wednesday, June 20, 2012 12:48 PM
All replies
-
open the webresource as a modal dialog and return the value from the html resource something like the following code.
var suburb = window.showModalDialog("http://tcrm2010:5555/CRM/WebResources/new_SuburbOption?data=" + param, false, 'dialogHeight:400px;dialogWidth:200px');
Xrm.Page.getAttribute("address1_city").setValue(suburb);in your webresource return the value when you click the button or any other control
window.returnValue=("parramatta");
window.close(); I hope this helps.If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Amreek Singh Senior CRM Consultant CDC Praxa Sydney, Australia http://mscrmshop.blogspot.com http://crm2011usersettings.codeplex.com
- Proposed as answer by Amreek Singh Tuesday, June 19, 2012 2:06 PM
Tuesday, June 19, 2012 2:06 PM -
hello karan u can mention the javascript in the web resource also u can u javascript directly in the webresourece
here in the below i just show the sample to call the javascript from html webrescource and u can call ur own javascript to make it
HTML><HEAD><BASE>
<SCRIPT type=text/javascript>
function myload()
{
var myVar = parent.Xrm.Page.getAttribute("").getValue();
var var1=parent.Xrm.Page.getAttribute("").getValue();
f(myVar!=null )
{document.getElementById("tr1").value=var1;
document.getElementById("tr2").value=myVar;
}<INPUT id=tr1name=xyx size=10> <INPUT id=tr2 name=USW size=10>
ur html rebresourcems crm
Tuesday, June 19, 2012 2:09 PM -
Hi Amreek,
I got some idea how to show data returned from html web resource in attributes of entity form.
Request you to please explain a bit how to open the html web res. as a modal dialog.
Any help link will be helpful.
Regards
Wednesday, June 20, 2012 9:14 AM -
That's what the first line of the code I posted is doing.
var suburb = window.showModalDialog("http://tcrm2010:5555/CRM/WebResources/new_SuburbOption?data=" + param, false, 'dialogHeight:400px;dialogWidth:200px');
In the above line, I m opening a modal dialog webresource named new_SuburbOption and passing a data parameter to it.
then i am returning the value from the resource using window.returnValue.
I hope this helps.
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Amreek Singh Senior CRM Consultant CDC Praxa Sydney, Australia http://mscrmshop.blogspot.com http://crm2011usersettings.codeplex.com
- Marked as answer by Karan Mittal Wednesday, June 20, 2012 1:25 PM
Wednesday, June 20, 2012 12:48 PM -
Thanks Amreek.
I mistakenly skipped reading that line.
It is really helpful and answered my query.
I also got help from your blog post http://mscrmshop.blogspot.in/2012/05/why-and-how-should-you-use-relative.html
Regards
Karan
Wednesday, June 20, 2012 1:33 PM