源代碼連接:https://github.com/TheMiao/Dynamics365CRM/blob/master/MyCRM/MyCRM/HelloWorld.cs
首先,我們需要創建一個.NET framework的class library.
其次, 我們要加入以下NuGet Package
接下來我們要assign 這個class
強名稱簽名使軟件組件具有全局惟一的標識
接下來, 我們要在HelloWorld class中引用 IPlugin interface.
我們創建這個plugin的功能是在description中添加string
首先,我們這里使用的是 late binding. 至於late binding 和early binding的比較, 我會在另外一篇中做詳細講解.
小插曲:
這里有碼農就會問了,那我怎么知道這個field的名字呢.
當我們點開Form, 找到相應的entity並且雙擊. 點開details 就能看到我們的name.
當我們寫好plugin並且保存之后, 我們需要deploy一下這個classlibrary. 這是為了項目可以生成對應的dll文件. Path: bin -> Debug -> (project name).dll
下一步, 我們要打開 plugin registration tool, 請連接你的instance.
登陸之后的界面
如果沒有register過, 點Register -> Register New Step
填寫Message 和 Primary Entity 信息之后, Execution stage選擇 PreOperation
之后 register我們的新 assembly plugin
register 成功之后,讓我們去建立一個新的contacts.
Description中就會有我們寫好的信息