Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript intellisense with Dynamics CRM 2011

Just wondering if there is anyway to have intellisense support whilst working on javascript files in Dynamics CRM 2011? I know that you can have this support if you use Visual Studio, however just wondering if there is any way we can do it within CRM app itself.

Any suggestions on this would be great!

like image 249
skub Avatar asked Feb 13 '12 23:02

skub


2 Answers

Sorry should have read more carefully before posting. But if you are using VS...

See http://blogs.msdn.com/b/crm/archive/2011/04/07/jscript-intellisense-for-form-script-libraries.aspx. I'm the writer for this part of the CRM SDK. I made this solution and included it in the SDK. It provides for JavaScript IntelliSense based on the structure and data found in a specific form. There is a Visual Studio extension and a supporting CRM managed solution.

This CRM SDK Topic introduces the solution: http://msdn.microsoft.com/en-us/library/gg328261.aspx.

This solution is a bit different from the other IntelliSense solutions because it actually implements most of the Xrm.Page functions so you get IntelliSense AND some capability to test your code against a snapshot of an individual form that contains data. You don't have to upload your files as web resources. You can do a sanity check first and avoid major debugging of the web resources from inside CRM.

What it does not do is provide the names of the individual form attributes you might want to reference (although the snapshot of the page data provides this in in an easy to read JSON format). It focuses on the syntax for the API and the available methods. If you type Xrm.Page.getAttribute('new_optionset'). you will only see the methods that are valid for an optionset attribute. While all attributes have getValue and setValue functions, not every attribute has a getOptions method. It does not require that any additional library be added to your script in order for them to work.

I think the other intellisense libraries are great. Thanks to those folks who made them. The solution I made has a bit more overhead but you get a different experience too. Use whichever one works for you.

like image 113
Jim Daly Avatar answered Nov 09 '22 22:11

Jim Daly


Since the script editor inside CRM is just a plain text box, I think the answer is no, and believe me I'm sorry to say that! You would think they'd at least have set the font to a true-type like courier to help a little bit with editing.

I find the easiest way is to use a lightweight text editor with syntax highlighting, like Notepad++. It's free, of course ;)

If you copy the code out of CRM's editor, paste it into Notepad++ and select JavaScript as the language, it'll give you the same syntax highlighting as Visual Studio but without associated load times (don't get me wrong, I love Visual Studio but it's massively overkill for a small JavaScript change). Also it'll let you set indentations properly. Then when you're done editing, copy and paste back into CRM.

I find this especially useful if I need to make a quick change on a machine where Visual Studio isn't available.

like image 29
Alec Avatar answered Nov 09 '22 23:11

Alec