Thursday, 12 March 2015

simple plug-in in crm 2013

for the simple plugin..

just open the class library:

add the required references

add the below code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using  Microsoft.Xrm.Sdk;
using  Microsoft.Xrm.Client;
using  Microsoft.Crm.Sdk.Messages;

namespace NamePlugin
    public class Class1 : IPlugin
        public IOrganizationService service;
        public IPluginExecutionContext context;

        public void Execute(IServiceProvider serviceProvider)
            IPluginExecutionContext context = (IPluginExecutionContext)

            Entity entity;

            // Check if the input parameters property bag contains a target
            // of the create operation and that target is of type Entity.
            if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)

                // Obtain the target business entity from the input parameters.
                entity = (Entity) context.InputParameters["Target"];

                string firstname = entity.Attributes["new_name"].ToString();
                string secondname = entity.Attributes["new_name1"].ToString();
                string fullname = firstname + " " + secondname;
                entity.Attributes["new_name2"] = fullname;


this is simple and register it in per-operation

No comments:

Post a Comment