locked
Using new Web API in Plugin and Workflow Assemblies RRS feed

  • General discussion

  • Hi Devs,

    Recently I started studying new Web API. I thought I should try it in my plugin and workflow assembly code. While searching for the same, I came across this below:

    Use the Web API for any projects that access Microsoft Dynamics CRM data with code that doesn’t run on the server, including XmlHttpRequests from web resources and form scripts that run in Microsoft Dynamics CRM application clients. At this time you can’t easily use the Web API for code that runs on the server, such as in plug-ins or workflow assemblies.

    Does this mean we should not start writing new Web API code that runs on the server?


    blog: <a href="http://technologynotesforyou.wordpress.com">http://technologynotesforyou.wordpress.com</a> | skype: ali.net.pk


    • Changed type Andrii ButenkoMVP, Moderator Wednesday, March 23, 2016 1:36 PM
    • Changed type Khadim Ali Sunday, March 27, 2016 7:51 PM The intention to ask this question was a general discussion
    • Edited by Khadim Ali Monday, April 25, 2016 9:16 PM title enhancement
    Wednesday, March 23, 2016 12:44 PM

All replies

  • If it is written I believe that it is the truth.

    Dynamics CRM MVP
    Read My blog
    Subscribe for one of my courses

    Wednesday, March 23, 2016 1:37 PM
    Moderator
  • Strictly, the consideration is that the new Web API is not designed to used for server code running within CRM (e.g. plugin / workflow assemblies), rather than any code running on the server. Put another way, if you were writing an external tool to connect to CRM with the new Web API, it would be fine to run it on the CRM server.

    My understanding is that the current plugin model is optimised around using the IOrganizationService instance that you derive from the plugin context, so any attempt to use the new Web API within a plugin would add a level of processing overhead


    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Wednesday, March 23, 2016 7:27 PM
    Moderator
  • Right, Andrii.

    The purpose I asked the question was as it was said " ... At this time you can’t easily use the Web API for code that runs on the server, such as in plug-ins or workflow assemblies", then still it's worth to go for a harder way to code server side in a new web API? From the wordings " ... at this time ..." I speculated if Microsoft might have plan to deliver this for plugin's code in any future release.


    blog: <a href="http://technologynotesforyou.wordpress.com">http://technologynotesforyou.wordpress.com</a> | skype: ali.net.pk


    • Edited by Khadim Ali Sunday, March 27, 2016 8:00 PM
    Sunday, March 27, 2016 7:48 PM

  • The purpose I asked the question was as it was said


    So is it a question or general discussion? If it is a question I believe you already got an answer. If it is general discussion - discuss. What do you want to discuss? I'm sorry but I don't get the point.

    Dynamics CRM MVP
    Read My blog
    Subscribe for one of my courses

    Monday, March 28, 2016 6:25 AM
    Moderator

  • So is it a question or general discussion? If it is a question I believe you already got an answer. If it is general discussion - discuss. What do you want to discuss? I'm sorry but I don't get the point.

    Dynamics CRM MVP
    Read My blog
    Subscribe for one of my courses

    Sorry for late reply. I intended just to have a little discussion on this topic. Discussions may include questions. As this was not a question that required any research to resolve any given development problem, so I thought it would be better to post it as a discussion rather than a question.

    However, I apologize if I didn't follow any of the guidelines to decide the type of post - a question or a discussion.


    blog: <a href="http://technologynotesforyou.wordpress.com">http://technologynotesforyou.wordpress.com</a> | skype: ali.net.pk


    • Edited by Khadim Ali Monday, April 25, 2016 3:28 PM
    Monday, April 25, 2016 3:27 PM
  • We can speculate on what might happen in the future, but the way I see things at the moment is:

    • The current plugin model with the IOrganizationService instance is as well optimised for performance as it can be. Using the new Web API now would definitely add performance overhead
    • If Microsoft were to allow direct use of the new Web API in plugins, I expect it would require a significant change to the plugin model, which seems a lot of work for not much benefit, so I doubt it's a priority

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Monday, April 25, 2016 3:57 PM
    Moderator
  • Right.

    Other than this, at this point of time using Web API calls in the plugin or custom workflow would mean working outside the plugin/workflow context. Any changes to the CRM using Web API then wouldn't be rolled back in case of exception.

    Ref: I read this some where in the social media discussion group.


    blog: <a href="http://technologynotesforyou.wordpress.com">http://technologynotesforyou.wordpress.com</a> | skype: ali.net.pk

    Monday, April 25, 2016 8:37 PM
  • That's correct, because with the new Web API you're not using the IOrganizationService instance that you derive from the plugin context. Only operations made through the IOrganizationService instance are treated as part of the plugin transaction

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Tuesday, April 26, 2016 8:05 AM
    Moderator
  • Web API is not designed to use for server code running within CRM (e.g. plugin / workflow assemblies). So it is not suggested to go with the WebAPI for Plugins and workflows.

     

    You may refer this blog for more information :

    http://inogic.com/blog/2016/03/programming-using-webapi-through-c-in-dynamics-crm-2016/

    Thanks,

    Sam


    Dynamics CRM MVP | Inogic | http://inogic.blogspot.com| news at inogic dot com

    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Tuesday, April 26, 2016 8:39 AM