Showing posts with label Plugins. Show all posts
Showing posts with label Plugins. Show all posts

Plugin to set records' names automatically

On each projects there are entities we can't force user to set names for (because it is needless). However it is good approach if all you records has names, especially if you have to choose these records in lookups.

I use plugins to set names of such entities. To simplify development of such plugins I did a base class and want to share it with you.

Let me show you example of the plugin which is based on SetNamePluginBase (base plugin) I share below.

using ExitoConsulting.Plugins.Base;
using Microsoft.Xrm.Sdk;

namespace ExitoConsulting.Plugins
{
    public class OwnerSetName : SetNamePluginBase
    {
        protected override string GetName(Entity entity, IPluginExecutionContext context, IOrganizationService service)
        {
            var fullName = entity.GetAttributeValue("ec_fullname");
            var clientId = entity.GetAttributeValue("ec_clientid");

            if(string.IsNullOrEmpty(fullName))
            {
                return null;
            }

            var name = fullName;
            if(!string.IsNullOrEmpty(clientId))
            {
                name = name + string.Format(" - {0}", clientId);
            }

            return name;
        }
    }
}

HOW TO: Organize Visual Studio Solution for Microsoft Dynamics CRM Customizations and Add-ons

Today I want to share how I organize Visual Studio Solution for small and medium size Microsoft Dynamics CRM implementation projects. For big projects solutions' structures are different and significantly depend on projects.

Below you can find common structure of a solution:

It doesn't mean that all solutions I did have the same structure. But all solutions have some or all projects from the list. Some solutions have even more projects.

Let me describe each project and folder one by one.

Unit testing CRM 2011 plugins. Approaches - Part 2

As promised I will explain two more approaches today.

I’m going to test same plugin as I tested in previous post. Plugin creates a task to qualify lead in two weeks each time lead is created. I use MS Test as unit testing framework.

Structure of the solution is explained in previous post. It much easy to get the thing right if you take a look on part 1: "Unit testing CRM 2011 plugins. Approaches - Part 1".

Unit testing CRM 2011 plugins. Approaches - Part 1

Today I want to describe two possible ways to unit test plugins. I will explain advantages and disadvantages of approaches.

I’m going to unit test a plugin which creates a task to call a lead in two weeks after lead creation. MS Test will be used as unit testing framework.

First of all let me give you overview of the Visual Studio solution. It consists of three projects:


HowTo.Logic – Class library. Contains business logic.
HowTo.SimplePlugin – Class library. Contains plugins.
HowTo.Tests – Test Project.

MS CRM 2011 Plugins FAQ

Following post contains frequently asked questions about plugins. You will find info about:
  • Isolation mode
  • Where secondary entity is used
  • Where to store plugin assemblies
  • Pre/Post Images, Target entity
  • How to access secure\unsecure configurations and what is the difference
  • Pipeline stages descriptions
  • e.t.c.

HOW TO: Create simple plugin in MS CRM 2011

Today I will describe how to create a simple plugin and register it in MS CRM 2011. Plugin will create a task each time user create new lead.
To do that I need: Visual Studio 2010 and .NET Framework 4.0 installed on my dev. machine, Microsoft CRM SDK.

1. Open Visual Studio and create new “Class Library” project.

2. Add new Reference

a. Press Add New Reference


b. Navigate to folder where you extracted Microsoft CRM SDK and select file
bin\microsoft.xrm.sdk.dll and press "Ok"