locked
Prevent Close Opportunity CRM 2011 RRS feed

  • Question

  • I am trying to add some loging to the opportunity close process.  I need to check the data and validate that some fields have been filled etc.  I would like to check when the user presses the "Close as Won" button to prevent the dialog from opening.  But even if I can't prevent the dailog from opening, I can't seem to stop the close command.  I've tried a solution that looked like it was designed for CRM4 but does not work in 2011. 

    Friday, September 23, 2011 6:31 PM

Answers

  • Hi,

    You can perform validations via JScript after user closes the Opportunity Close window and can cancel the event as mentioned in the following post: http://worldofdynamics.blogspot.com/2011/08/dynamics-crm-2011-perform-jscript.html (for Oppoirtunity close Save event code value is 5, make sure to replace the code value into the script)

    Also you can develop a plugin and can register it on opportunity entity for OpportunityClose message and can perform the requried validations and if validations failed then can throw InvalidPluginExuecution exception to abort execution. You can access the Opportunity object in plugin i.e.

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

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

    Guid opptyId = opptyRef.id;

     


    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".
    Friday, September 23, 2011 6:45 PM
  • You should use a plugin and register it on close of opportunity. In your plugin you can do the required validation and if the validation fails you need to throw an exception with an error message that will be displayed to the user.

    Gonzalo | gonzaloruizcrm.blogspot.com

    Friday, September 23, 2011 6:41 PM
    Moderator

All replies

  • You should use a plugin and register it on close of opportunity. In your plugin you can do the required validation and if the validation fails you need to throw an exception with an error message that will be displayed to the user.

    Gonzalo | gonzaloruizcrm.blogspot.com

    Friday, September 23, 2011 6:41 PM
    Moderator
  • Hi,

    You can perform validations via JScript after user closes the Opportunity Close window and can cancel the event as mentioned in the following post: http://worldofdynamics.blogspot.com/2011/08/dynamics-crm-2011-perform-jscript.html (for Oppoirtunity close Save event code value is 5, make sure to replace the code value into the script)

    Also you can develop a plugin and can register it on opportunity entity for OpportunityClose message and can perform the requried validations and if validations failed then can throw InvalidPluginExuecution exception to abort execution. You can access the Opportunity object in plugin i.e.

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

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

    Guid opptyId = opptyRef.id;

     


    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".
    Friday, September 23, 2011 6:45 PM