locked
CRM Form Button + Open New Aspx page for pop up aspx page? RRS feed

  • Question

  • Hi professionals, I want to open the aspx page on the click of ribbon button available in the entity form then user enter some fields on the form then click submit it will automatically be created in the entity form which user clicked button.

    Any help?

    Monday, September 16, 2013 1:53 PM

Answers

  • Yes, you can use the

    Xrm.Utility.openWebResource("URL");

    to open up the external web page - I'd make sure that you pass it the extra parameters so that it'll work as expected - in particular the width and height. You don't want it opening up over the top of your CRM form.

    Xrm.Utility.openWebResource("URL.htm", null, 300,300);
    

    I've done this quite often on our CRM system and find that some things are better when they are not stored as web resources. Once you've got the web page to open up, you can write whatever you need in there. My advice would be to use JavaScript on the web page to send the data back to the form. I'm assuming that you're OK with JavaScript here.

    Create the form on the web page with a button wherever you want it - but make sure that this button is not of type "submit" but just a standard "button". Add an onclick to the button to call a function and, in that function, you can reference the form on the page and the CRM form together to pass the information over. You'll need the command

    parent.Xrm.Page.data.entity.attributes.get("new_attribute").setValue("Something");
    to send data from the web page back to CRM. Of course, by running this command, your web page will expect this attribute to be there and, if it's not, it will throw an error. But this should give you what you need to get started.
    • Marked as answer by Adeel Aqdus Wednesday, September 18, 2013 1:16 PM
    Tuesday, September 17, 2013 8:45 AM

All replies

  • If you are talking about CRM 2011 than you will have to use html page instead of aspx. You can add html page as a web resource and open it using window.open command. OR you can open this page in an iframe.


    Regards Faisal

    Monday, September 16, 2013 3:11 PM
  • Hello,

    you can also use

    Xrm.Utility.openWebResource("URL");

    to open html webresource,

    Also check how you can send parameter to html webresource


    Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Monday, September 16, 2013 4:24 PM
    Moderator
  • Yes, you can use the

    Xrm.Utility.openWebResource("URL");

    to open up the external web page - I'd make sure that you pass it the extra parameters so that it'll work as expected - in particular the width and height. You don't want it opening up over the top of your CRM form.

    Xrm.Utility.openWebResource("URL.htm", null, 300,300);
    

    I've done this quite often on our CRM system and find that some things are better when they are not stored as web resources. Once you've got the web page to open up, you can write whatever you need in there. My advice would be to use JavaScript on the web page to send the data back to the form. I'm assuming that you're OK with JavaScript here.

    Create the form on the web page with a button wherever you want it - but make sure that this button is not of type "submit" but just a standard "button". Add an onclick to the button to call a function and, in that function, you can reference the form on the page and the CRM form together to pass the information over. You'll need the command

    parent.Xrm.Page.data.entity.attributes.get("new_attribute").setValue("Something");
    to send data from the web page back to CRM. Of course, by running this command, your web page will expect this attribute to be there and, if it's not, it will throw an error. But this should give you what you need to get started.
    • Marked as answer by Adeel Aqdus Wednesday, September 18, 2013 1:16 PM
    Tuesday, September 17, 2013 8:45 AM
  • Can you please send me the hello world solution?
    Wednesday, September 18, 2013 1:17 PM
  • You'll need a basic html page like this...

    <html>
    
    <head>
    	<script type="text/javascript">
    		function sendToCRM()
    		{
    			var inputbox1variable = document.myForm.inputbox1.value;
    			parent.Xrm.Page.data.entity.attributes.get("new_attribute1").setValue(inputbox1variable);
    			var inputbox2variable = document.myForm.inputbox2.value;
    			parent.Xrm.Page.data.entity.attributes.get("new_attribute2").setValue(inputbox2variable);
    		}
    	</script>
    </head>
    
    <body>
    	<form name="myForm">
    		<input name="inputbox1" type="text">
    		<br>
    		<input name="inputbox2" type="text">
    		<br>
    		<input type="button" value="Submit form" onclick="sendToCRM()">
    	</form>
    </body>
    
    </html>

    Hopefully you can see how it works. The <body> has a form containing various elements, including a "Submit" button that fires the JavaScript code which takes the value from all the elements, puts them into variables and then passes them to the CRM form.

    This will only work if it's launched from within CRM. You'll need to have some web space that you can use in order to store it - then just refer to the URL that it's stored at when you use the Xrm.Utility.openWebResource in CRM.

    Friday, September 20, 2013 10:42 AM