locked
Custom plugin and caching RRS feed

  • Question

  • Hello,

    I need to write a plugin that will get some values from a service on an external server. I would like to cache the result of those values. Important to note here is that the plugin will run sandboxed because it concerns the CRM Online service from Microsoft that is being hosted, so no on-premise install!

    I've been reading for a while now on possibilities

    First I got excited about the SysGlobalObjectCache, but if I understand correctly this is a Dynamics AX thing and so not available in CRM? Right? 

    Second I found that just creating a custom entity for it and then use that a a caching mechanism. I like the idea, but not the security configurations that are needed for this. I do not want regular users to be able to CRUD this entity using forms.

    Third I've read I could just put a static ConcurrentDictionary on my plugin class. I like this, but what about the lifetime of this? Can I expect this to live as long as the appdomain or since these plugin are running sandboxed will this be a futile attempt as they get reset every time the plugin executes?

    Another issue I'm facing is how to get this cached value using javascript? In the second scenario it's obvious because I would be retrieving it using the organization service or will this be trouble since normal users are not allowed to read this if it is configured properly?

    In the other cases I have no clue yet as to how to get it done. Any feedback?

    This is what I've got so far...

    Hope anyone can help me out here.

    Regards,

    Filip

    Thursday, November 29, 2012 10:51 AM

Answers

  • In CRM Online, you will not be able to host a WCF service in a plugin.  While technically possible in an OnPremise deployment, you will be limited by the maximum lifetime (2 minutes) of a synchronous plugin - if the plugin is asynchronous, then perhaps it would be possible - but again, not a chance in CRM Online (sandboxed environment in which you will not possess the requisite privileges).

    In CRM Online, the only logical option that comes to mind is a Custom Entity (would be my preference) - you can restrict access to this data via Security Roles if the information is sensitive.


    --pogo (pat) @ pogo69.wordpress.com

    Friday, November 30, 2012 7:11 AM

All replies

  • I think second option is the best option available for you. If you don't want to give CRUD operation to regular users simple don't display them in sitemap. and using JavaScript you could easily retrieve data from them.

    and even if you think some users could access them from some where write simple javascript on load and on save of the form to disable the fields in the form.

    I hope this helps. If my response answered your question, please mark the response as an answer and also vote as helpful.
    Mubasher Sharif
    Check out my about.me profile!
    http://mubashersharif.blogspot.com
    Linked-In Profile
    Follow me on Twitter!

    Thursday, November 29, 2012 11:11 AM
  • Thanks for your suggestion.

    Do you know by any chance if it possible to add a custom REST services that exposes some functionality? I see these service endpoints thing i the customizations, but not sure if this is what I think it is. Maybe it is possible to setup a wcf service host in a plugin? Just brainstorming here :-)

    Regards,

    Filip

    Thursday, November 29, 2012 12:10 PM
  • Yes it is possible to call a wcf service host in a plug.
    Here is a link to call WCF from plugin

    http://nishantrana.wordpress.com/2010/11/20/calling-wcf-service-in-plugin-in-crm/

    I hope this helps. If my response answered your question, please mark the response as an answer and also vote as helpful.
    Mubasher Sharif
    Check out my about.me profile!
    http://mubashersharif.blogspot.com
    Linked-In Profile
    Follow me on Twitter!

    Thursday, November 29, 2012 1:17 PM
  • Well that calling is possible I figured out already, my question was if it is possible to host a service.
    Thursday, November 29, 2012 1:22 PM
  • In CRM Online, you will not be able to host a WCF service in a plugin.  While technically possible in an OnPremise deployment, you will be limited by the maximum lifetime (2 minutes) of a synchronous plugin - if the plugin is asynchronous, then perhaps it would be possible - but again, not a chance in CRM Online (sandboxed environment in which you will not possess the requisite privileges).

    In CRM Online, the only logical option that comes to mind is a Custom Entity (would be my preference) - you can restrict access to this data via Security Roles if the information is sensitive.


    --pogo (pat) @ pogo69.wordpress.com

    Friday, November 30, 2012 7:11 AM