Javascript 智能感知与 Dynamics CRM 2011
只是想知道在 Dynamics CRM 2011 中处理 javascript 文件时是否有智能感知支持?我知道如果您使用 Visual Studio,您可以获得此支持,但只是想知道我们是否有任何方法可以在 CRM 应用程序本身中做到这一点。
任何关于这方面的建议都会很棒!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
请参阅 http: //blogs.msdn.com/b/crm/archive/2011/04/07/jscript-intellisense-for-form-script-libraries.aspx。
我是 CRM SDK 这一部分的编写者。我制作了这个解决方案并将其包含在 SDK 中。
它提供基于特定形式的结构和数据的 JavaScript IntelliSense。有一个 Visual Studio 扩展和一个支持 CRM 托管解决方案。
此 CRM SDK 主题介绍了解决方案: http://msdn.microsoft.com/en-us/library/ gg328261.aspx。
此解决方案与其他 IntelliSense 解决方案略有不同,因为它实际上实现了大多数 Xrm.Page 函数,因此您可以获得 IntelliSense 和一些功能,可以根据包含数据的单个表单的快照来测试代码。您不必将文件作为网络资源上传。您可以先进行健全性检查,避免从 CRM 内部对 Web 资源进行重大调试。
它不提供您可能想要引用的各个表单属性的名称(尽管页面数据的快照以易于阅读的 JSON 格式提供了该名称)。它重点介绍 API 的语法和可用方法。如果您输入 Xrm.Page.getAttribute('new_optionset')。您只会看到对选项集属性有效的方法。虽然所有属性都有 getValue 和 setValue 函数,但并非每个属性都有 getOptions 方法。
它不需要将任何额外的库添加到您的脚本中即可使其工作。
我认为其他智能感知库都很棒。感谢那些制作它们的人。我提出的解决方案有更多的开销,但你也会得到不同的体验。使用适合您的任何一种。
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.
由于 CRM 内的脚本编辑器只是一个纯文本框,我认为答案是否定的,相信我,我很抱歉这么说!你可能会认为他们至少将字体设置为像 courier 这样的真实字体,以帮助编辑。
我发现最简单的方法是使用带有语法突出显示的轻量级文本编辑器,例如 Notepad++。当然,它是免费的;)
如果您从 CRM 编辑器中复制代码,将其粘贴到 Notepad++ 中并选择 JavaScript 作为语言,它将为您提供与 Visual Studio 相同的语法突出显示,但没有相关的加载时间(不要获取我错了,我喜欢 Visual Studio,但对于 JavaScript 的一个小更改来说它太过分了)。它还可以让您正确设置缩进。然后,当您完成编辑后,复制并粘贴回 CRM。
如果我需要在无法使用 Visual Studio 的计算机上进行快速更改,我发现这特别有用。
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.
您需要将文件 XrmPage-vsdoc.js 添加到 VS2010 中的项目中,然后将对其的引用添加
到 *.js 文件的顶部,这样您就可以使用 IntelliSense。
有关详细信息,请参阅这篇文章 CRM 2011:IntelliSense对于 Xrm.Page
You need to add file XrmPage-vsdoc.js to your project in VS2010 and then add a reference to it like this
to the top of your *.js file and you'll get working IntelliSense.
For more information look at this post CRM 2011: IntelliSense for Xrm.Page
看一下 Shrpr Web 资源编辑器,它具有语法突出显示、大括号匹配和一些简单的代码完成功能(不是完整的智能感知,但仍然值得)。
http://www.shrpr.org/2011 /11/shrpr-web-resource-editor-first-release.html
(也有后续版本,但第一个公告包含了大部分信息)
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).
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)