The code examples I link to today will be for CRM 2011 but the basic methodology is the same for 4.0 also.
Here is how this works:
1. First you need to create a new custom entity to act as a trigger entity, I'll often times even name this new custom entity "new_trigger{plugin name}"
2. Now you must register your plug-in (or several plug-ins) on the create or update messages for this new entity. (I usually prefer the create message for my registrations because a new record will be created which keeps a record or audit-trail of who manually executed your plug-in and when in the created by and created time-stamp attributes on the entity)
3. You must create a jscript web resource that contains a function that performs a soap update or create call on the entity depending on which message you registered your plug-in on.
4. Lastly you must add your web resource to your form and call your update or create jscript function on one of the exposed form events (OnLoad, OnSave, etc...). You can also call your jscript function from ribbon button if you want.
I hope this helps!
-
We also used a different approach but somewhat similar.
ReplyDeletewe had a flag on the entity and from the Jscript we update the flag and also register the plugin on the update of this flag.
That would be another way to approach the problem. I just don't like the answer that I see in the forums all too often that it cannot be done. :)
ReplyDeleteI have implemented this solution, the call is working, but I can't get any data back out to javascript.
ReplyDeleteIf anyone can help, I have posted this on stackoverflow
http://stackoverflow.com/questions/22815111/how-to-return-output-to-client-side-rest-call-from-microsoft-xrm-sdk-iplugin