Wednesday, August 24, 2011

Dynamics CRM 2011 : Opportunity Plugin Update Message Trigger on Opportunity Record Creation


On creating opportunity record if plugin is registered for Update event then it will automatically trigger and the code written for the Update event will be executed, to prevent from this erroneously behavior you can add a condition to check if plugin parent Context execution message is null then execute the code.

 [Plugin: C# Code]


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Metadata;
using Microsoft.Crm.Sdk;

namespace wod.Crm.PluginDebugger
{
    public class wodPlugin : IPlugin
    {
        public void Execute(IServiceProvider serviceProvider)
        {
            // Obtain the execution context from the service provider.
            IPluginExecutionContext context = 
            (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

            // check if parenet context message is Create and current contetx message is Update then return 
            //and does not execute code.
            if (context.MessageName == "Update" && context.ParentContext != null && 
                context.ParentContext.MessageName == "Create")
            {
                return;
            }
            else
            {
                // Write your update Opportunity record code here
            }

        }
    }
}



12 comments:

  1. Yoou mаde some good points there. I looked on the
    net tߋ find out more about tɦe issue and found most individսals will go along with your views on this site.

    ReplyDelete
  2. cheap louis vuitton handbags
    Everyone loves it when individuals come together and share
    ideas. Great website, stick with it!

    ReplyDelete
  3. Thanks in support of sharing such a good thought, article is pleasant, thats
    why i have read it fully

    ReplyDelete
  4. What's up, every time i used to check webpage posts here early
    in the dawn, as i love to learn more and more.


    Also visit my web-site; Family Guy The Quest for Stuff cheatt for clams

    ReplyDelete
  5. I got this site from my buddy who informed me concerning
    this web site and now this time I am visiting this
    website and reading very informative content at this time.


    My webpage croazia appartamenti vacanze sul mare

    ReplyDelete
  6. Choose the roofing company that will do the job right and at a fair price.

    This is the time with your house reconstruction will get underway with instruction from the builder.
    Want to own your business and work out of your home.

    Feel free to visit my homepage; roofing contractor

    ReplyDelete
  7. Tiffany UK To pick a copy Tiffany
    UK bag does not necessarily mean that yo have waste materials yo funds considering that thei Sale Tiffany Rings good-nfaiing and qaity mateias.(Israeli security Tiffany UK)SDSStrategic Safeguard SystemWant to thank TFD due
    to its existence? A backyard heatedtennis and pool, Tiffany Expensive jewelry
    and shuffleboard can all be part of your days and nights routines.Cheap survivalrafts Tiffany

    Feel free to surf to my web blog ... uk tiffany and co outlet

    ReplyDelete
  8. Hello, I think your site might be having browser compatibility issues.
    When I look at your blog site in Chrome, it looks fine but
    when opening in Internet Explorer, it has some overlapping.
    I just wanted to give you a quick heads up!
    Other then that, great blog!

    My web site; Prosolution

    ReplyDelete
  9. Rispondi al 13 ° piano, @ lisaasd




    Se l'uomo chiamato outlet hogan marchea quanto casa dote, vi suggerisco di essere forte nel tuo cuore



    [Messaggio scarpe hogandel mani dell'orizzonte]

    --------------------------

    Inizialmente borse hoganproposto dal suo
    ragazzo, ha detto di essere quattro auto cerchio ...


    Non ero tranquillo, gli dissi dopo che i
    miei genitori hogan uomoavrebbero prendere la seconda casa preservativo
    per noi, e ha parlato molto, è anche convenuto, ma poi tornare
    il giorno dopo per dire che hogan bambinoera,
    lui non era d'accordo con la ...

    La sua famiglia è il suo controllo padre mano, macho ...






    Look into my blog hogan interactive

    ReplyDelete
  10. On creating opportunity record if plugin is registered for Update event then it will automatically trigger and the code written for the Update event will be executed, to prevent from this erroneously behavior you can add a condition to check if plugin parent Context execution message is null then execute the code.
    web developer designer vancouver ,
    web development in vancouver ,

    ReplyDelete