CRM 2013 online revise quote executes plugin for Create pre-op event? RRS feed

  • Question

  • I have a custom plugin that is registered on Quote Create - pre-Operation. it works fine in CRM 2011 and CRM 2013. However, in CRM 2013, whenever I revise the quote, this plugin fires!!  Is there something I need to do to stop this in CRM 2013. 
    // The InputParameters collection contains all the data passed in the message request.
                if (context.InputParameters.Contains("Target") &&
                    context.InputParameters["Target"] is Entity)
                    //EntityReference entityref = (EntityReference)context.InputParameters["Target"];
                    Entity entity = (Entity)context.InputParameters["Target"];
                    // Verify that the target entity r
                    if (entity.LogicalName == "quote") entityname = "QUOTE";
    This plugin was migrated to CRM 2013.  Do I need to register for CRM 2013 with any thing special? Appreciate your thoughts 

    • Edited by CRM elite Monday, December 9, 2013 5:48 PM
    Monday, December 9, 2013 5:47 PM

All replies

  • When a quote is revised, CRM creates a new quote and copies the original quote information. All the information will be same except that the revision number is incremented in the revised quote. If you want to perform some operation only on new quote and not on a revised one then check for the revision number field.

    If my response helps you in finding your answer then please click 'Mark as Answer' and 'Vote as Helpful'

    Monday, December 9, 2013 6:06 PM
  • Hi mamatha, thanks for the quick feedback. I was actually on this track and appreciate you confirming it. But on a pre-operation, how can i read the revision number property of the quote record.  If the quote is created for the first time, will I be able to read the quote record using entity.id in order for me to check the property? appreciate if you could help me with a sample code line here 
    Monday, December 9, 2013 6:22 PM
  • I try to check for the quoterevisionnumber on Pre-Operation,  but I am getting error message that the quote record doesn't exist. Which is correct, because it is created for the first time and I am running this check on pre-operation event. 
      var qu = (from a in svcContext.CreateQuery<Quote>()
                                          where a.QuoteId == entity.Id
                                          select a).FirstOrDefault();
                                if (qu !=null)
                                    if (qu.RevisionNumber > 0)
                                    { return; }
    [Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=, Culture=neutral, PublicKeyToken=xxxxxxxxx35]]: Exception occured during the Custom plugin Execution.
    quote With Id = xxxxxxxxxxxx325224245xxxx63242xxxxxxxxxxx Does Not Exist
    Monday, December 9, 2013 6:48 PM
  • thoughts / some help from anyone? Appreciate it. 
    Monday, December 9, 2013 7:24 PM
  • Hi,

    When quote record creates first time, Revision ID is always zero and if quote gets revised then Revision ID always greater than zero. I have never done this before but you could try to read Revision ID attribute in your pre create plugin, if this is zero that means quote created first time. 

    Hope this helps. If you get answer of your question, please mark the response as an answer and vote as helpful !!!
    Vikram Singh. !!!  My Blog

    • Edited by _Vikram Tuesday, December 10, 2013 3:00 AM
    Tuesday, December 10, 2013 2:57 AM
  • It seems to be impossible to add related items (custom relationships) when revising a quote. Does anyone have a solution for this?



    Thursday, December 11, 2014 8:16 AM