locked
Plug-in for quote RRS feed

  • Question

  • Hi Forum,

    I am new to CRM developing. I am trying to create a plug-in that writes a certain value into a custom field, when a quote created.

    I used one of the sdk samples as a starter. I registered the plugin using the plugin registration tool and copied my assembly in to the servers bin\assambly folder. When I create a new quote nothing happens. Is there a way to determine why or even to remote debug the code?

    Here is my code fragment:

          DynamicEntity entity = null;
    
          // Check if the input parameters property bag contains a target
          // of the create operation and that target is of type DynamicEntity.
          if (context.InputParameters.Properties.Contains("Target") &&
             context.InputParameters.Properties["Target"] is DynamicEntity)
          {
            // Obtain the target business entity from the input parmameters.
            entity = (DynamicEntity)context.InputParameters.Properties["Target"];
            // Verify that the entity represents a quote.
            if (entity.Name != EntityName.quote.ToString()) { return; }
          }
          else
          {
            return;
          }
          try
          {
            StringProperty angebotsnr = new StringProperty("new_angebotsnummer", "Generated by plugin");
            entity.Properties.Add(angebotsnr);
          }
          catch (System.Web.Services.Protocols.SoapException ex)
          {
            throw new InvalidPluginExecutionException("Die Angebotsnummer kann nur ...", ex);
          }
    
    
    
    
    TIA
    Alex
    Monday, August 10, 2009 10:36 AM

Answers

All replies

  • Hi, Alex.

    Have you registered step?
    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    Monday, August 10, 2009 10:40 AM
    Moderator
  • Yes I have, with these settings. I have no idea what images are. Can you please explain?

            <Steps>
              <Step PluginTypeName="BEAElectrics.CRM.Plugins.Angebotsnummer" 
                    PluginTypeFriendlyName="9dc98a43-260e-435f-b1bc-6b87cac76b90" 
                    CustomConfiguration="" 
                    SecureConfiguration="" 
                    Description="Create of quote in Parent Pipeline" 
                    FilteringAttributes="" 
                    ImpersonatingUserId="" 
                    InvocationSource="0" 
                    MessageName="Create" 
                    Mode="0" 
                    PrimaryEntityName="quote" 
                    SecondaryEntityName="none" 
                    Stage="50" 
                    SupportedDeployment="0" 
                    Rank="1" 
                    Id="c0840c3d-9285-de11-aef9-00155d00421d">
                <Images />
              </Step>
            </Steps>
    Alex
    Monday, August 10, 2009 10:45 AM
  • Hi, Alex.

    What is Eventing pipeline stage of Execution - Pre Stage or Post Stage?
    For image sense read this article .

    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    Monday, August 10, 2009 10:52 AM
    Moderator
  • It's Post Stage. Is the code okay. Should it fill the field?
    Monday, August 10, 2009 10:55 AM
  • Hi, Alex.

    To make this property to be saved you have to re-register this step to pre create entity. Your code adds new property after this record is saved to DB. Check Event Execution Pipeline article.

    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    Monday, August 10, 2009 10:57 AM
    Moderator
  • Thanks for the hints.

    It is working, but only if I create a quote directly. It is not working when I add a quote to an oppotunity. Why is that? Is there a possibility to execute the plugin when the form is loaded? I mean that it is executed before I save the record?

    Alex
    Monday, August 10, 2009 11:38 AM
  • Hi, Alex.

    Could you write your scenario when plugin doesn't fire?
    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    Monday, August 10, 2009 11:40 AM
    Moderator
  • When I create a quote, without any parent entities involved the plugin is started. But when I create an opportunity first and add a quote to the opportunity (which is the process we are using) then the plugin is not started and the field remains empty when I save the quote.
    Monday, August 10, 2009 12:10 PM
  • Hi, Alex.

    Try to register step on Child Pipeline (not parent like now)
    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    Monday, August 10, 2009 12:11 PM
    Moderator
  • Thanks, that did the trick.
    Monday, August 10, 2009 12:24 PM