In case you have ever wondered or needed to know, here is how you get the ID of the current user using .NET (C# in this case):

var whoAmIResponse = (WhoAmIResponse)OrganizationService.Execute(new WhoAmIRequest());

var currentUser = new EntityReference(SystemUser.EntityLogicalName, whoAmIResponse.UserId);

Hi Everyone,

Registration closes for the Plug-in Development Workshop on Thursday so now is the time to register.

Eventbrite - Plug-in Development with Dynamics CRM (April)

 

Here are what some of my former students have to say:

I found Mitch Milam’s workshop to be a great way to jump-start my plug-in development. Besides presenting class material in such a way that it was easy to comprehend, Mitch also provided Visual Studio templates. These templates proved to be extremely useful because they take care of the necessary plumbing when writing plug-ins, speeding up the development time. Additionally, the labs we worked on in class covered real-life scenarios directly applicable to my day-to-day work. In fact soon after the workshop, I solved a business problem by building a plug-in that was based on one of the labs we worked on in class.

Natalya Pinsker, Baltimore, MD

   

Mitch’s Plug-in Development workshop helped me get out of the gate and a good way down the path of C# development for Microsoft Dynamics CRM – including both Plug-ins and Workflow Assemblies. Mitch is an excellent instructor who responds to all questions and helps people along at their own pace. I highly recommend this workshop for anyone who is looking to get into the Microsoft CRM development game. It will accelerate your process and save you more than enough time to pay for itself.

Aron F.

   

Your class was an eye opening experience. In addition to learning about Plug-In Development this class exposed me to so many other aspects of Microsoft Dynamics CRM that I was not aware of.

Marlon R. Joseph, Application Analyst III, Houston Baptist University

 

You may get more details about this workshop here.

Thanks, Mitch

I am holding another Dynamics CRM Plugin Development workshop this month. The goal of the class is for me to teach you everything I know about plugin development.

When: Monday, April 21st through Thursday, April 24th. 1:00pm – 5:00pm CST each day.

Where: Online

What: This is a hands-on workshop with each student provided their own virtual development environment for the duration of the class

Cost: $895 per person (multi-student discounts available)

Note: Due to the interactive nature of this workshop, it will be limited to 10 students.

Eventbrite - Plug-in Development with Dynamics CRM (April)

Note: Registration closes at 10:00pm CDT.

Agenda:

  • Plugin architecture and design
    • The Dynamics CRM execution pipeline
    • The how, why, and where of plugging into Dynamics CRM
    • Performance considerations
    • Working in the sandbox
  • The development environment
    • Setup
    • Source control
    • Working in teams
  • Deploying plugins
    • To CRM
    • In a solution
    • To CRM Online (if applicable to the student population)
  • Debugging plugins
    • Synchronous vs. asynchronous
    • Full-trust vs. sandboxed
  • Custom activity architecture
  • Design features
  • Deployment
  • Asynchronous process monitoring
  • System job cleanup and maintenance
  • Open-lab time
  • Upgrade scenarios
  • Code-recovery of lost source plugin code

Thanks to our virtual development environments, the majority of our time will be spent actually designing and developing real-world plugins. Think labs. Lots and lots of labs. In fact, here is the list:

Plug-In Exercises:

  • Exercise 1: Autonumber – DateTime
  • Exercise 2: Autonumber – QueryExpression
  • Exercise 3: Autonumber – SQL
  • Exercise 4: Create Related Records
  • Exercise 5: Generate a Formal Name
  • Exercise 6: Handling Exceptions
  • Exercise 7: Multi-Entity Plugin
  • Exercise 8: Monitoring Plug-In Depth
  • Exercise 9: Auto-Assign Records
  • Exercise 10: Zip Code Lookup
  • Exercise 11: Child Record Rollup
  • Exercise 12: Data Validation
  • Exercise 13: Audit Log

Custom Workflow Activity Exercises:

  • Exercise 1: Route a New Lead
  • Exercise 2: Verify Email

In addition to the workshop materials, each student will receive additional tools and code templates to help increase their productivity as a Dynamics CRM plug-in developer.

Finally, all students are free to keep any work produced during their lab-time as well as the tools and templates used in class.

So picture this: I am trying to get my very own C# t-shirt by compiling the Xamarin Store App using Visual Studio (Xamarin Studio on the Mac works just fine).

I am having an issue deploying the app to the iOS Simulator so I can run it. Unfortunately, the only feedback I am receiving was Deploy Failed (check the logs).

So I check the logs. Nothing. So I open a support ticket with Xamarin and Allie gives me several things to check.  Still Nada.

At this point I’m getting a bit frustrated because I am thinking it cannot be this hard, so I start digging around and do a detailed examination of any log I can find (on the PC or the Mac).

 

Issue Number 1

This was when I find the issue. If you open the Console App, you will see a folder called Simulator, along with sub-folders for each application that you have run via the Simulator:

image

I clicked on the App whose name started with XamarinStoreIOS and as you can see on the right, the error is clearly visible.

So technically, this was not a Deployment Error, but in actuality, a run-time error.  But, since the application did not start, Visual Studio reported that it did not deploy.

So that is issue number one.

 

Issue Number 2

Issue number two the runtime exception:

[05-Apr-2014 10:48:05] Error: Tool MonoTouch.Tools.Tools.ContentCopier failed to run
[05-Apr-2014 10:48:05] Exception: Exception type: System.InvalidOperationException
Source file '/Users/mitch/Library/Caches/Xamarin/mtbs/builds/XamarinStoreiOS/fc7e7851-4a32-4b43-a9e6-f68ac1ef613e/bundle/Shared/Images/button-image.png' does not exist
  at MonoTouch.Tools.Tools.ContentCopier.RunInner (MonoTouch.Tools.Tools.RunInfo ri) [0x00000] in <filename unknown>:0 
  at MonoTouch.Tools.Tools.ToolBase.Run () [0x00000] in <filename unknown>:0 
  at Mtb.Server.Commands.Build.RunTools (System.Collections.Generic.List`1 tools, ILoggingHelper logger) [0x00000] in <filename unknown>:0

Why am I missing this file?

It turns out, the solution is in the way the file was linked into the iOS project in Visual Studio. This is the XML from the .csproj file, concerning the button-image.png file:

<BundleResource Include="..\Shared\Images\button-image.png">
      <Link>Resources\button-image.png</Link>
</BundleResource>

The image is the same across all three projects of the Xamarin Store App so rather than just add the file to each project, they merely created a reference link to the master copy, which is in the Shared project.

 

The Solution

The problem is this does not seem to be properly including this file into the iOS build process so when the binary get’s to the Mac, it is not bundled into the final executable.

I also found a similar issue with the TaskyPro sample app. A similar issue existed with one of the shared text files that was referenced from the Shared project.

I corrected the issue by simply adding the button-image.png file as an item in the iOS project, which solved the immediate problem of failing to deploy and run.

A bug has been created in Bugzilla, if you’re interested.

Hi Everyone,

Version 3.2 of SnapShot! has been released.

I made minor changes to this release, mainly around the Status and Status reason fields. They are now included on the Field report and the OptionSet report.

Visit the SnapShot! product page for more information and to download the sample report.

As always, thanks for your support and let me know if you have any suggestions for additional reports.

Thanks, Mitch

Every now and then I run into an issue that I should have already known about.  Either that, or I knew about it and later forgot.  Regardless, let me tell you the story of the plug-in and the missing data.

 

Background

Let us say that I have a plug-in that is registered on the Create message for the Account entity. When a new Account is created, it will automatically populate a custom field with the name of the Primary Contact using code that looks like this:

var primaryContact = entity.GetAttributeValue<EntityReference>("primarycontactid");

entity["new_primarycontactname"] = 
    string.Format("{0}-{1:d}", primaryContact.Name, DateTime.Now);

This is pretty simple CRM SDK work that most of us do on a daily basis without much thought whatsoever.  All I am doing is taking the display name from the Entity Reference and using that value, along with the current date, to populate my custom field.

When the record is created with the CRM user interface, this code works perfectly. But, and there is always a but, what if we create the Account using an SDK call?

The answer is: It does not work so perfectly.

When you are creating an Entity record using the SDK the common method for creating an Entity Reference is to use code like this:

entity["primarycontactid"] = new EntityReference(Contact.EntityLogicalName, 
                                      Guid("9C06869F-50C6-E211-8D6B-00155D1E5005"));

This is the minimum requirement for populating an Entity Reference (Lookup) field using the SDK, and is generally how everyone does it.

 

The Problem

The problem is our plug-in.  Since the plug-in is registered on the Create message, it will fire for each Account being created, no matter if the record is coming from the Dynamics CRM web client, from a Scribe or SSIS job, or in this case, from a customer-facing web portal.

Since we did not specify the .Name property on our primarycontactid field, it will arrive inside of the plug-in as a Null value.

This means my plugin code will produce: "-4/8/2014” instead of “John Smith-4/8/2014.

This is not a bug in CRM, this is just the way it works.

 

The Work Around

So if we indeed need the .Name property on the Entity Reference, we need to either specify it in our code, like this:

var primaryContact = new EntityReference(
                              Contact.EntityLogicalName, 
                              new Guid("9C06869F-50C6-E211-8D6B-00155D1E5005"));
primaryContact.Name = "John Smith";

entity["primarycontactid"] = primaryContact;

OR, and this is not exactly a good thing, perform a read, from within the plug-in, of the Entity record referenced and pull back the primary field, like this:

var contact = organizationService.Retrieve(
                 patientReference.LogicalName, 
                 patientReference.Id, 
                 new ColumnSet(new[] { "fullname" }));

return patient["fullname"].ToString();

Anyway, this is something to keep in mind should you have an applications integrated with your Dynamics CRM system.

Our monthly Dallas/Ft. Worth CRMUG meeting is this Wednesday, April 9th, from 12:00 pm to 1:30 pm Central.

If you are in the area, then please stop by to learn and share all things Dynamics CRM (plus a free lunch).

This month, Torry Landry is sharing with us the following trick:

In the Sales world we want to know which customers do NOT have a particular product so we know what we can offer.  Unfortunately, it is really difficult to search for “null” within CRM.  I scoured the CRM forums and learned how to isolate such a population. 

Last month we had a great Q&A session so this month, again bring your tips, tricks, and questions to share and ask the group.

You can register for the meeting here:

http://www.crmug.com/events/crmugdallas4914

 

Thanks, Mitch

,

Hi Everyone,

Registration of this month’s workshops is now open.

Please let me know if you have any questions.

 

Plug-in Development with Dynamics CRM

Monday, April 21th through Thursday, April 24th. 1:00pm-5:00pm each day.

Eventbrite - Plug-in Development with Dynamics CRM (April)

 

JavaScript Development with Dynamics CRM

Monday, April 28th through Thursday, May 1st. 1:00pm-5:00pm each day.

Eventbrite - JavaScript Development with Dynamics CRM (April)

 

Pricing

Pricing will be $895 per student, per workshop, with multiple-student and multiple-workshop discounts available.

Due to the interactive nature of the workshop, there is a limit of 10 students per workshop.

Hi Everyone,

Next month I will be holding two workshops for CRM developers:

 

Plug-in Development with Dynamics CRM

Monday, April 21th through Thursday, April 24th. 1:00pm-5:00pm each day.

 

JavaScript Development with Dynamics CRM

Monday, April 28th through Thursday, May 1st. 1:00pm-5:00pm each day.

 

Pricing

Pricing will be $895 per student, per workshop, with multiple-student and multiple-workshop discounts available.

Due to the interactive nature of the workshop, there is a limit of 10 students per workshop.

 

Registration

Registration will open on Thursday, April 3rd.

To pre-register and secure your seat now, enter your information on the April Workshops sign-up page.

If you are doing any work at all with Dynamics CRM 2011 or 2013 you need to become a friend of PowerShell.  Because PowerShell can be a really good friend who will save you much time and trouble.

 

The Basics

There are several pre-packaged solutions to help you get started with PowerShell.  Here are a few:

Dynamics CRM SDK

The SDK has several sample scripts in the SampleCode\ps folder that show you how to exercise the PowerShell commandlets that ship with Dynamics CRM 2011 and 2013.

 

Adxstudio ALM Toolkit

http://www.adxstudio.com/products/adxstudio-alm-toolkit/

Is a Lifecycle Management for Microsoft Dynamics CRM Application Solutions with both free and commercial versions.

 

xRM CI Framework

http://waelhamze.com/2013/08/20/automated-crm-deployments-powershell/

Is a development and testing framework that contains several PowerShell components to aid in your development and deployment efforts.

Developing Your Own CommandLets

I have had great success developing my own PowerShell commandlets to perform functions that are customer or job-specific.  Prior to PowerShell, I would have create a .NET Console application. By using PowerShell, I can create a single-use commandlet that I simply plug into my project that will give me the desired functionality.

In most cases, the code you write is fairly small and all you really need is to pass in a CRM OrganizationService object.  I’ll have some posts in the future that describes how to do that.

In the meantime, to get you started, install this package:

PowerShell Tools for Visual Studio

http://visualstudiogallery.msdn.microsoft.com/c9eb3ba8-0c59-4944-9a62-6eee37294597

This will give you some really cool PowerShell functionality within Visual Studio.

And visit this page for instructions on how to get starting writing your own:

Writing a Windows PowerShell Cmdlet

http://msdn.microsoft.com/en-us/library/dd878294(v=vs.85).aspx

Sign up for our new KnowledgeBits service and get news, tips and tricks and more, delivered straight to your inbox.