locked
While deactivating record,update plugin get fire. RRS feed

  • Question

  • Hello,

              I have created one custom plugin with "PreStage Create Mode" and "Pre-Stage Update Mode" for Client entity . Whenever I Create or Update Records plugin works fine.But whenever I try to deactivate record plugin for "Pre-Stage Update Mode" get fired and error message displayed in update mode get displayed.

             I just want to restrict that Update Plugin Code to be fired on Deactivation  of record.What could be the solution.Can anybody please help me?

    Tuesday, April 9, 2013 8:49 AM

Answers

  • Pls check if the filtering attributes is selected only "mcg_name"  when register the pre-operation update stage


    微软CRM

    • Marked as answer by Prashant Wani Tuesday, April 9, 2013 10:01 AM
    Tuesday, April 9, 2013 9:41 AM
    Moderator

All replies

  • Could you share you code here ?

    Contact Me
    Follow me on Twitter
    My Facebook Page
    Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Tuesday, April 9, 2013 8:56 AM
    Moderator
  •  if (_context.MessageName == UPDATE_MESSAGE)
                    {
                        statusCode = (GetAttributeValue<OptionSetValue>("statuscode")).Value;                    
                        decimal Fbudget=0;

                        using (OrganizationServiceContext orgContext = new OrganizationServiceContext(_service))
                        {

                            recordName = GetAttributeValue<string>("mcg_name");

                            validfrom = GetAttributeValue<DateTime>("mcg_validfrom");
                            validto = GetAttributeValue<DateTime>("mcg_validto");

                            statusCode = (GetAttributeValue<OptionSetValue>("statuscode")).Value;

                            fundBudget = GetAttributeValue<Money>("mcg_budget");
                        }



      if (_entityTarget.Attributes.Contains("mcg_name"))
                        {
                            QueryExpression qrFundDuplicateName = new QueryExpression("mcg_fund");
                            qrFundDuplicateName.Criteria = new FilterExpression();
                            qrFundDuplicateName.ColumnSet = new ColumnSet("mcg_name");
                            qrFundDuplicateName.Criteria.AddCondition("mcg_name", ConditionOperator.Equal, recordName);
                            qrFundDuplicateName.Criteria.AddCondition("mcg_fundid", ConditionOperator.NotEqual, recordId);
                            EntityCollection fundEntityCollection = _service.RetrieveMultiple(qrFundDuplicateName);

                            if (fundEntityCollection.Entities.Count > 0)
                            {
                                throw new InvalidPluginExecutionException("Entered fund name is already used,please try another one.");
                            }
                        }
              }

    When I click on deactivate button "Entered fund name is already used,please try another one." is coming.I want to restrict the same.

                                                  
    Tuesday, April 9, 2013 9:16 AM
  • Pls check if the filtering attributes is selected only "mcg_name"  when register the pre-operation update stage


    微软CRM

    • Marked as answer by Prashant Wani Tuesday, April 9, 2013 10:01 AM
    Tuesday, April 9, 2013 9:41 AM
    Moderator