locked
Creating Organization Service Inside a Plugin RRS feed

  • Question

  • Hi,

    Is there a way to create separate OrganizationService instance within a plugin without "hard-coding" the server URL to bypass plugin transaction rollback when any exception thrown in a plugin?  Is there any way to retrieve it from within the plugin context itself?

    Regards,

    Andre


    • Edited by Andre.K.MMVP Thursday, February 6, 2014 12:41 AM
    Thursday, February 6, 2014 12:30 AM

Answers

  • I don't believe there is a way to retrieve this from the plugin context. It might be possible to use reflection to get this, but that won't work in the sandbox

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

    • Marked as answer by Andre.K.MMVP Thursday, February 6, 2014 10:40 PM
    Thursday, February 6, 2014 2:58 PM
    Moderator

All replies

  • Hi Andre,

        You can always put the server URL in a separate entity like configuration etc. It is always a best practice to have a configurations like this in a separate entity and read from there in plug-in etc.


    Hope this helps.
     
    -----------------------------------------------------------------------
     Minal Dahiya
    blog : http://minaldahiya.blogspot.com.au/

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

    • Proposed as answer by Minal Dahiya Thursday, February 6, 2014 12:36 AM
    Thursday, February 6, 2014 12:36 AM
  • Hi,

    I've been thinking of this, but it is inconvenient to setup separate configuration. Is there any way to retrieve it from within the plugin context itself?

    Thanks

    Thursday, February 6, 2014 12:39 AM
  • I don't believe there is a way to retrieve this from the plugin context. It might be possible to use reflection to get this, but that won't work in the sandbox

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

    • Marked as answer by Andre.K.MMVP Thursday, February 6, 2014 10:40 PM
    Thursday, February 6, 2014 2:58 PM
    Moderator
  • Thanks David, I spent the whole day yesterday, and come to a conclusion that seems there is no way to do this on Sandbox plugin. Thanks for mentioning reflection, it might be come in handy for Non-sandbox plugin. Unsure whether it is by design that we could not retrieve that or it could be a feature for improvement in future.
    • Edited by Andre.K.MMVP Thursday, February 6, 2014 10:41 PM grammar clarification
    Thursday, February 6, 2014 10:40 PM
  • Hi

    Check this blog post. Do you think this can help?

    http://crmtidbits.blogspot.com/

    • Proposed as answer by Ahmad Pirani Monday, February 10, 2014 5:09 PM
    Monday, February 10, 2014 5:09 PM