MS CRM心得 - 從Hosk's blog開始談plugin

首先介紹一位我個人非常喜歡的MS CRM MVP大神: Hosk. 


這個是他的blog鏈接:

https://crmbusiness.wordpress.com/


他不同於別的MS CRM大神,他的文章都十分生動且會聯繫自身的一些例子,讀起來讓人一氣呵成又獲益匪淺。 今天就從他的一篇博客出發談一談一個讓人又愛又恨的CRM開發問題: Plugin


1. deploy 工具

Hosk大神和我一樣,常用的插件註冊工具有兩個: developer toolkit 和 plugin registration tools. 這兩個工具都可以在crm 2013以及之前的版本都可以從SDK中得到,但自2015之後微軟就不提供developer toolkit了, 免費的替代品比如Jason大神在codeplex上發佈的自己開發的toolkit 和 付費的solution manager在一定程度可以起到和developer toolkit一樣的作用。


2. 作用

plugin 是server side的code, 當有些功能無法通過CRM 前端觸發而且out of box的workflow和business rule又無法實現如此複雜的邏輯的時候, 你就必須要考慮使用plugin去實現這個功能


3. event piple

a. pre-validation 

發生在form validation之前,不包括在database transcation中,也就是說不需要驗證user的permission就可以觸發,所以使用起來要特別慎重。

例子:一個由delete parent entity 觸發的plugin, 由於delete cascade發生在pre-validation的時候,如果需要獲得child entity的信息,就需要把step註冊在pre-validation

b. pre-operation

顧名思義,發生在事件之前。

例子:設置默認值或者需要驗證的plugin

c.post-operation

觸發在事件發生之後。

例子: 在create record之後再create child record.


4 Isolation Mode

sandbox vs none

首先要注意的是CRM online的plugin 必須註冊在sandbox isolation mode下。

而註冊在sandbox mode下有很多限制: 

MSDN的解釋是: Access to the file system, system event log, certain network protocols, registry, and more is prevented in the sandbox.


Hosk的limitation list::

  • Access to the file system (C Drive)
  • system event log
  • certain network protocols
  • registry
  • You cannot access any other DLL’s
  • You cannot call any webservices from within a sandboxed plugin
  • IP addresses cannot be used
  •  Only the HTTP and HTTPS protocols are allowed.
  • In isolated mode you cannot call any external DLL’s\DLL’s in the GAC  
看完這些限制,你會發現除了第三方的dll 和 webservice之外, 你很少會在plugin上涉及到其他限制的資源,但是如果使用on premise版本的話還是強烈推薦使用none的mode,因爲在debug的時候實在方便太多。


接下來的第二篇關於plugin的心得準備記錄下一些關於debug, 和out of box function的優劣,和custom workflow的差別。 


PS: 歡迎大家評論來討論關於CRM的問題:)。



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章