locked
How to remove the attribute from the Target Input parameter, MS CRM 2013 Online. RRS feed

  • Question

  • Hi,

    I want to prevent plugin core operation from pre-operation pipeline. I went through this post. Recommended solution says, "remove the attribute from the Target Input parameter" to achieve this. How to  remove the attribute from the Target Input parameter ? If not achievable, how to prevent core operation using plugin?


    Thanks and Regards. Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Wednesday, July 16, 2014 7:35 AM

All replies

  • Try this

        Context.InputParameters.Remove("fieldname")


    Our Website| Our Blog | Follow US | 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.

    Wednesday, July 16, 2014 7:48 AM
    Moderator
  • HI Mahender,

    Thanks for the reply.

    Below is the code i have used in the plugin, and registered on Update Message, Pre-Operation. But record(name field also) is getting saved. Could you help me ?

                // The InputParameters collection contains all the data passed in the message request.
                if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
                {
                    Entity entity = (Entity)context.InputParameters["Target"];
                  
                    // TODO - Plugin code goes here
                    bool resultBool = true;
                    if (resultBool == true)
                    {
                        context.InputParameters.Remove("name");
                    }
                    else if (resultBool == false)
                    {
                        entity["name"] = "updated On False";
                        service.Update(entity);
                    }
                }


    Thanks and Regards. Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Wednesday, July 16, 2014 12:03 PM
  • Hi,

    You are assigning entity before deleting attribute ,Try this

    bool resultBool =true;

    if(resultBool)

    {

    context.InputParameters.Remove("name");

    }

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


    Our Website| Our Blog | Follow US | 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.

    Wednesday, July 16, 2014 1:46 PM
    Moderator