locked
CRM 2011 JScript calling plugin code. RRS feed

  • Question

  • In our current CRM4 system, we have business logic implemented in JScript, and we consider it bad practice because JScript should only handle "client-side" logic.

    Now we are in the process of updating to CRM 2011. I am wondering if it's possible to invoke plugin code written in C# from Jscript's "onchange" functions( sort of like letting the controller handle the business logic in .net MVC framework) . If this is not possible, is using Silverlight the only way of implementing the business logic in C#?

    Thanks a lot.

     

    Friday, June 24, 2011 7:20 PM

Answers

  • When CRM client post a message (Create, Update, Delete, etc.) to CRM server, it can trigger CRM plugin code to be executed (either Pre stage or Post stage). But the execution of such plugin code is not controlled by the client, except the fact that the client is the one who initiates such request which triggers the plugin.

    That said, for the important business rules, you might have to implement twice, using client script and plugin code respectively.


    Daniel Cai | http://danielcai.blogspot.com
    Friday, June 24, 2011 8:23 PM

All replies

  • JavaScript is a client technique, which cannot be used to call CRM plugin code, though it can be used to make CRM service calls, but that's a different story. Silverlight is also a client technology, which has the same limitation.


    Daniel Cai | http://danielcai.blogspot.com
    Friday, June 24, 2011 7:56 PM
  • The client side code cannot directly invoke server side code. But, is there a way of sending messages to server and "trigger" the server code to run, similar to what the .net mvc framework does?  Also, the webform's "code behind" also allows developers who are not very kin of writing JavaScript to write code in C#.  
    Friday, June 24, 2011 8:10 PM
  • When CRM client post a message (Create, Update, Delete, etc.) to CRM server, it can trigger CRM plugin code to be executed (either Pre stage or Post stage). But the execution of such plugin code is not controlled by the client, except the fact that the client is the one who initiates such request which triggers the plugin.

    That said, for the important business rules, you might have to implement twice, using client script and plugin code respectively.


    Daniel Cai | http://danielcai.blogspot.com
    Friday, June 24, 2011 8:23 PM
  • When CRM client post a message (Create, Update, Delete, etc.) to CRM server, it can trigger CRM plugin code to be executed (either Pre stage or Post stage). But the execution of such plugin code is not controlled by the client, except the fact that the client is the one who initiates such request which triggers the plugin.

    That said, for the important business rules, you might have to implement twice, using client script and plugin code respectively.


    Daniel Cai | http://danielcai.blogspot.com
    Thanks! I think this is the kind of info I need.
    Friday, June 24, 2011 9:07 PM
  • I don't think it's bad practise to use javascript to provide client side logic and plugins to do more complex updating of variables.

     

    I agree with the other posters, why don't you fire off the plugin from a create/update/delete etc message and still have javascript doing client side code.

     

     


    Ben Hosking
    Check out my CRM Blog
    Linked-In Profile
    Follow Me on Twitter!Follow Me on Twitter!
    Saturday, June 25, 2011 12:27 AM
  • I would still argue that client side code should not have any knowledge about business logic. The "client side logic" should be limited to "show/hide/enable/disable" certain parts of pages depending on end-users' input.

    Things like retrieving information from external systems should when a user logs in should be kept on the server side. Therefore the ability to trigger server side code at events such as "Form_onLoad" should be provided. 

    Monday, June 27, 2011 5:31 PM