locked
How to access an opportunity entity in a CRM 2011 plugin when closing the opportunity RRS feed

  • 问题

  • I need to fire a plugin when closing an opportunity, get the opportunity id and retrieve and close a bunch of related "opportunity detail" records.  I have registered the plugin for both the Win and Lose messages as a synchronous post-operation step, and it does fire when closing an opportunity.  The problem is that I can't figure out how to get the opportunity id of the opportunity that was just closed.

     

    I have tried

    Entity

     

     

    entity = (Entity)context.InputParameters["opportunityclose"

    ];

     

     

    and 

    Entity

     

    entity = (Entity)context.InputParameters["Target"

    ];

     

     

     

     

    2011年8月23日 20:34

答案

全部回复

  • Hi,

    Try like this:

    Entity entity = (Entity)context.InputParameters["OpportunityClose"];


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    2011年8月23日 21:05
  • using the following code to get the opportunity which is to win or lose:

    Entity opptyClose = (Entity)context.InputParameters["OpportunityClose"];

    EntityReference opptyRef = opptyClose["opportunityid"] as EntityReference;

    Guid opptyId = opptyRef.id;


    daemon lin
    2011年8月24日 6:31
  • Hi, I need to create a plug-in that fires after an opportunity is closed as won. 

    I tried to register this plug-in in the WIN message of OPPORTUNITY Entity. Plugin doesn't fire. 

    However, I registered a step in Create of Opportunity Close. I am able to get the opportunity ID. However, it fires for both Win or Lose event. 

    How do I retrieve the Opportunity ID that is just closed as Won?

    2012年7月15日 18:28