简体   繁体   English

使用Dynamics CRM 2011进行Javascript智能感知

[英]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? 只是想知道在动态CRM 2011中处理javascript文件时是否还有智能感知支持? 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. 我知道如果您使用Visual Studio,您可以获得此支持,但只是想知道我们是否可以在CRM应用程序本身中执行此操作。

Any suggestions on this would be great! 对此的任何建议都会很棒!

Sorry should have read more carefully before posting. 对不起应该在发布之前仔细阅读。 But if you are using VS... 但如果你正在使用VS ......

See http://blogs.msdn.com/b/crm/archive/2011/04/07/jscript-intellisense-for-form-script-libraries.aspx . 请参阅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. 我是CRM SDK这一部分的作者。 I made this solution and included it in the SDK. 我制作了这个解决方案并将其包含在SDK中。 It provides for JavaScript IntelliSense based on the structure and data found in a specific form. 它基于特定形式的结构和数据提供JavaScript IntelliSense。 There is a Visual Studio extension and a supporting CRM managed solution. 有一个Visual Studio扩展和一个支持CRM托管的解决方案。

This CRM SDK Topic introduces the solution: http://msdn.microsoft.com/en-us/library/gg328261.aspx . 此CRM SDK主题介绍了该解决方案: 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. 此解决方案与其他IntelliSense解决方案略有不同,因为它实际上实现了大多数Xrm.Page函数,因此您可以获得IntelliSense和一些功能,可以根据包含数据的单个表单的快照来测试代码。 You don't have to upload your files as web resources. 您不必将文件上传为Web资源。 You can do a sanity check first and avoid major debugging of the web resources from inside CRM. 您可以先进行健全性检查,避免从CRM内部对Web资源进行重大调试。

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). 它没有做的是提供您可能想要引用的各个表单属性的名称(尽管页面数据的快照以易于阅读的JSON格式提供)。 It focuses on the syntax for the API and the available methods. 它侧重于API的语法和可用的方法。 If you type Xrm.Page.getAttribute('new_optionset'). 如果键入Xrm.Page.getAttribute('new_optionset')。 you will only see the methods that are valid for an optionset attribute. 您将只看到对optionset属性有效的方法。 While all attributes have getValue and setValue functions, not every attribute has a getOptions method. 虽然所有属性都有getValue和setValue函数,但并非每个属性都有getOptions方法。 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. 我认为其他intellisense库很棒。 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. 使用适合您的任何一个。

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! 由于CRM中的脚本编辑器只是一个纯文本框,我认为答案是否定的,相信我很抱歉这样说! 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++ . 我发现最简单的方法是使用带语法高亮的轻量级文本编辑器,如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). 如果您将代码复制到CRM的编辑器中,将其粘贴到Notepad ++中并选择JavaScript作为语言,它将为您提供与Visual Studio相同的语法,但没有相关的加载时间(不要误会我的意思,我喜欢Visual Studio但是,对于一个小的JavaScript更改来说,这是非常过分的。 Also it'll let you set indentations properly. 它还可以让你正确设置缩进。 Then when you're done editing, copy and paste back into CRM. 然后,当您完成编辑,复制并粘贴回CRM。

I find this especially useful if I need to make a quick change on a machine where Visual Studio isn't available. 如果我需要在Visual Studio不可用的机器上进行快速更改,我发现这特别有用。

You need to add file XrmPage-vsdoc.js to your project in VS2010 and then add a reference to it like this 您需要在VS2010中将文件XrmPage-vsdoc.js添加到项目中,然后像这样添加对它的引用

///<reference path="..\IntelliSense\XrmPage-vsdoc.js"/>

to the top of your *.js file and you'll get working IntelliSense. 到你的* .js文件的顶部,你将获得工作IntelliSense。 For more information look at this post CRM 2011: IntelliSense for Xrm.Page 有关更多信息,请查看此文章CRM 2011:IntelliSense for Xrm.Page

Have a look at the Shrpr web resource editor which has syntax highlighting, brace matching and some simple code completion (not full intellisense, but still worth it). 看一下Shrpr Web资源编辑器,它具有语法高亮,大括号匹配和一些简单的代码完成(不是完整的智能感知,但仍然值得)。

http://www.shrpr.org/2011/11/shrpr-web-resource-editor-first-release.html http://www.shrpr.org/2011/11/shrpr-web-resource-editor-first-release.html

(there are later releases too, but the first announcement had most information in) (也有后来的版本,但第一个公告中有大部分信息)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM