locked
CRM 2011 HTML/JavaScript WebResourse Issues RRS feed

  • Question

  • I posted this question last night and this morning it is gone. This is the second question I posted that disappeared over night.  Hopefully these are not getting lost! 

    I've been working with CRM 2011 the past few weeks and I have been building some HTML pages and using JavaScript.  However, I am running out of time to determine how best to implement a few things.  So I am hoping to get some ideas, thoughts, suggestions, maybe code snippets, etc. from others that might have already gone this route.

    What I am doing is replacing some dialogs with HTML pages because they cannot do some things that I need.  So I have been working through how to build HTML/JavaScript pages in CRM and moving the work the dialog is doing over to the HTML page.  However, I am having a couple of issues.

    1. Email...  can you create an email template in CRM then via JavaScript use that template to send an email? 

    2. How do you load a dropdown list from an HTML/JavaScript web resource and using the REST JQuery service?  I have a custom entity with a name field and I would like to load a dropdown list with these names.  I've seen examples, but they are not very good in regards to explaining how to do this.  I've coded this up a few different ways but cannot get it to work. So I am looking for a good example of how to do this. 

    3. I have been calling the "Lookup record" form from my HTML page, but I cannot get it to work in IE9.  When the lookup page pops up, the size of the window is not being controlled by the JavaScript.  I know that the code is correct, as if I change the URL to other pages, it works fine.  But when I call the lookup record form and set it's height to say 800 and it's with to say 500, it resizes to only show the first sentence at the top.  It ignores the height and width settings.  On my HTML pages, I am adding lookup fields and I would like to use the built-in lookup record form to maintain consistency between my custom pages and the CRM forms.

    4. I suspect that with the need to email and the need to load the dropdown lists, that maybe this would better fit a plugin.  With the plugin at least I can focus on C# and not JavaScript, so I suspect it would be easier to work with.  Also, I don't like the idea of hitting the db with JavaScript anyway.  I've always preferred using an architecture of some sorts with a datalayer as a class library or web service.  It seems putting db code in client-side JavaScript is maybe not the best approach.  So plugins seem to be a better design.  Has anyone else considered this and made similar decisions?  Did it work out well? 

    Any thoughts, suggestions, or samples are much appreciated.  My main concern right now is getting the dropdown list working and the loopup form to show up correctly.  If you are doing this and it is working for you, please share how you are able to get this to work for IE9.

    Best regards,

    Jon Rothlander


    Jon Gregory Rothlander

    Tuesday, February 25, 2014 3:35 PM

Answers

    1. Sending e-mail through Javascript is not a trivial task, but it can be done using the SendEmailRequest or the SendEmailFromTemplateRequest. These requests can be issued to the SOAP webservice endpoint of CRM.
    2. Loading dropdown lists can be done by retrieving metadata from the SOAP endpoint. You can find an example here: http://guruprasadcrm.blogspot.nl/2011/07/retrieving-optionset-lable-data-using.html
    3. I would not encourage you to use the Lookup dialog. It is a complex object that has been revised for every version of CRM up to 2013. Maybe it is an option to develop something yourself?
    4. Whenever possible I prefer to develop plugins instead of Javascript. .NET/C# code is easier to develop and CRUD operations always pass your plugin, which is not true for Javascript.

    If this post is an answer or helpful, please do not forget to vote!

    • Marked as answer by jonrothlander Friday, February 28, 2014 2:57 PM
    Tuesday, February 25, 2014 8:53 PM

All replies

    1. Sending e-mail through Javascript is not a trivial task, but it can be done using the SendEmailRequest or the SendEmailFromTemplateRequest. These requests can be issued to the SOAP webservice endpoint of CRM.
    2. Loading dropdown lists can be done by retrieving metadata from the SOAP endpoint. You can find an example here: http://guruprasadcrm.blogspot.nl/2011/07/retrieving-optionset-lable-data-using.html
    3. I would not encourage you to use the Lookup dialog. It is a complex object that has been revised for every version of CRM up to 2013. Maybe it is an option to develop something yourself?
    4. Whenever possible I prefer to develop plugins instead of Javascript. .NET/C# code is easier to develop and CRUD operations always pass your plugin, which is not true for Javascript.

    If this post is an answer or helpful, please do not forget to vote!

    • Marked as answer by jonrothlander Friday, February 28, 2014 2:57 PM
    Tuesday, February 25, 2014 8:53 PM
  • Henk,

    Thanks for your answers and taking the time to respond.  Your suggestions have helped me a great deal.  I made more progress yesterday building C# plugins that I had in a week trying to build JavaScript code to do the same thing!  If you wouldn't mind, can you explain one thing about you said in point #4?

    In regards to your point #4 - I agree about using C# when you can. JavaScript is painful and tedious to work with. If I can lean on C# over JavaScript, then I will be in a much better postion. In that regards, I have HTML web resources to replace some very complex dialogs. But to get these to work I have had to do everything in JavaScript. I really do not like having to do data-access in client-side JavaScript.  How can I move this over to .Net/C#? I don't think a plugin can help me here. Is there something else I can do so that in my HTML web resources and in JavaScript, I just call out to .Net/C# classes? I guess a web-service would be reasonable, but that will not work in an off-line context. How would you approach this? 

    Best regards,

    Jon Rothlander 

     


    Jon Gregory Rothlander


    Friday, February 28, 2014 3:12 PM
  • You can develop your UI extensions in .NET, e.g. ASP.NET/MVC. However, there are a few considerations to take into account:

    1. Dynamics CRM 2011/2013 does no longer support adding custom web pages to the ISV folder, so you would need to setup a separate website. In an on-premise deployment you can host this website on the same server CRM is installed on and bind it to a different port number. Benefits of this approach are simplicity, no need for separate web servers and no cross-site scripting challenges on the client side. When you run your custom website with the same AppPool identity CRM is running on,
    2. In Dynamics CRM Online things get a bit more complicated. Here your extension can not be deployed on the CRM server, because you have no access to the server/VM CRM is running on. But, you can in fact still integrate your web application with CRM. First you would need to make the solution single signon. To achieve this your web application must use WIF (Windows Identity Foundation) and you have to configure CRM and your application to make it rely on the same security context. Second, you would need a CRM user account to enable your application to access CRM server-side. Client-side your integration options are a bit restricted, due to cross site scripting protection in browsers. Scripts running in your custom ASPX-pages can therefore not access CRM's OData endpoint and will not be able to access CRM's pages directly. Communication between CRM pages and custom pages can only be done through the page url's query string parameters.

    Still, web development moves more and more towards richer clients. Luckily, when it comes to developing 100% webresource-based UI extensions, modern Javascript libraries can help you a lot reducing complexity. A few popular libraries I favour are:

    • JQuery
    • KnockoutJS (I really love the way it simplifies databinding)
    • Jasmine (unit test framework)

    Whenever possible, use the OData endpoint and JSON. The CRM SDK provides some useful code examples and library functions that give you a good start. Also, some extensions for Visual Studio can ease the pain of developing pure HTML web applications for CRM (Web Essentials, CRM Solution Manager).


    If this post is an answer or helpful, please do not forget to vote!



    Sunday, March 2, 2014 1:42 PM