Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Simple Plugin performance too slow.. but only sometimes

$
0
0

Hi community,

I have developed a very simple plugin, just some calculations on some Account fields (3 fields), registered at Update message, filtered by those fields, pre-operation, sync, running on D365.

Usually the plugin takes <50 to run, but sometimes it takes a long wait, >15000.

I have read around about first execution of plugin being slow after some inactivity, but can't belive this is the way, as it makes some users having to wait a long time until save completes, let's say 15 / 20 seconds, and in my oppinion the plugin useless.

Actually, this happens to me in other plugins also, but I choose this case as it's a very simple calculation, no queries, no external services, only a simple calc.

Some execution statistics:

Thanks in advance!!!

Plugin Execute code

            IPluginExecutionContext context = (IPluginExecutionContext)
                serviceProvider.GetService(typeof(IPluginExecutionContext));

            if (!context.InputParameters.Contains("Target")) return;
            var target = (Entity)context.InputParameters["Target"];

            Entity image;
            if(!context.PreEntityImages.TryGetValue("Target", out image))
            {
                image = new Entity("account");
            }
//NOTHING SPECIAL HERE var accountWrapper = new AccountWrapper(image); accountWrapper.UpdateWith(target); //THIS CLASS JUST HAS THE CALCULATION LOGIC, INCLUDED BELOW FOR REFERENCE
var accountNextContactLogic = new AccountNextContactLogic(); var fechaProximoContactoNueva = accountNextContactLogic.ComputeAccountNextContactDate(accountWrapper); if (accountWrapper.FechaDeProximoContacto != fechaProximoContactoNueva) { target["ent_fechadeproximocontacto"] = fechaProximoContactoNueva; }


 AccountNextContactLogic code

                var proximoContacto = (account.FechaUltimaOperacion > account.FechaUltimaActividad || !account.FechaUltimaActividad.HasValue)
                    ? account.FechaUltimaOperacion
                    : account.FechaUltimaActividad;
                //agrego frecuencia
                proximoContacto = proximoContacto?.AddDays(account.FrecuenciaContacto ?? 0);
                //verifico que no supere la fecha no contactar antes de
                if(account.NoContactarAntesDe > proximoContacto) proximoContacto = account.NoContactarAntesDe;

                return fechaProximoContactoNueva;



Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>