Monday, 7 May 2012

Changes in CRM 2011 plugins


There are a lot of syntax and functional changes in MSCRM 2011 plugins. I have listed some of them below:

1. New References
• System.ServiceModel
• System.Runtime.Serialization

2. Microsoft.Crm.Sdk has been replaced by Microsoft.Xrm.Sdk

3. The default parameter for execute method has been changed from
IPluginExecutionContext to IServiceProvider

public void Execute(IServiceProvider serviceProvider)


serviceProvider
A container for service objects. Contains references to the plug-in execution context (IPluginExecutionContext), tracing service (ITracingService), organization service (IOrganizationServiceFactory), and notification service (IServiceEndpointNotificationService).

4. IpluginExecutionContext has been changed to a type of service and to get the reference use the following syntax.

IPluginExecutionContext context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));

5. ICrmService has been changed to IOrganizationService

IOrganizationServiceFactory serviceFactory =
IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

6. Dynamic entity has been changed to “Entity”

if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)
{
Entity entity = (Entity)context.InputParameters["Target"];
}


7. Dynamic Entity’s properties syntax has been changed to attributes

entity.Attributes.Contains("accountnumber")

8. Strongly typed classes (account, contact) are missing in Microsoft.XRM.Sdk assembly but there is an exception to this.

9. CRM 2011 provides the crm utility called “crmsvcutil” to generate strongly typed classes that can be used in plugins.

10. Strongly typed classes has been changed to use like loosely typed classes.
Task task = new Task();
Task[“description”] = ”test description”

11. No more soap exception
catch (FaultException ex)


Below given template can be used to create a plugin for the MS CRM 2011

using System;
using System.ServiceModel;
using System.Runtime.Serialization;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Messages;

namespace MyPlugin
{
public class MyPlugin : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
 IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
 if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
 Entity entity = (Entity)context.InputParameters["Target"];
 if (entity.LogicalName != "entity logical name”)
 { return; }
try
{
IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = factory.CreateOrganizationService(context.UserId);
//Plugin Code
 }

catch (FaultException ex)
 { 
throw new InvalidPluginExecutionException("An error occurred in the plug-in.", ex);
}
}
}
}
}

Enjoy CRM !!!

Thursday, 18 August 2011

Service Accounts


        Local System : Completely trusted account, more so than the administrator account. There is nothing on a single box that this account can not do and it has the right to access the network as the machine (this requires Active Directory and granting the machine account permissions to something)
      
      Network Service : Limited service account that is meant to run standard least-privileged services. This account is far more limited than Local System (or even Administrator) but still has the right to access the network as the machine (see caveat above).
         
      Local Service : A limited service account that is very similar to Network Service and meant to run standard least-privileged services. However unlike Network Service it has no ability to access the network as the machine.

Cheers !!!

Tuesday, 26 July 2011

Extending CRM 2011 - Microsoft Official Course Launched

It gives me a lot of joy to post about the Microsoft's Latest launched course , "Extending CRM 2011 (Instructor Led) ".

You can find the related information by clicking here


About this CourseThis course offers detailed and interactive information on how to develop extensions for Microsoft Dynamics CRM 2011, with focus on extension methods documented in the Microsoft Dynamics CRM SDK.  It provides instruction on the use of a number of Common Platform Operations, on how to query and execute these operations, as well as on developing a concise understanding of business process implementation and workflows.  In addition, the course describes how to use Plug-ins, application event programming, client extensions and web resources.  Finally, it includes a summary overview of the integration between Windows Azure and Microsoft Dynamics CRM 2011.
Audience Profile
This course is a CRM development course intended primarily for partners and customers who have a technical background and familiarity with Microsoft Dynamics CRM 4.0 or Microsoft Dynamics CRM 2011.  The audience must also be experienced in basic form customizations and workflows.

Enjoy CRM........

Cheers !!!

Friday, 24 June 2011

Pictures in CRM Email

One of my biggest issues with CRM emails, versus an Outlook email, is how difficult it can be to tailor up your emails that you want to send out. Getting a good looking email sent out of CRM is about as complex as writing a static web page. And since CRM emails are rendered in HTML, that's actually exactly what it takes to get a good looking email out.

Now, not everyone wants to send out an amazing document all the time, sometimes a picture or logo at the end of the email would suffice. Theoretically this would be simple, only CRM doesn't let you copy and paste images from your local machine into an email.

But there is a solution, it doesn't require too much effort, but it does require whatever image you want to be sent in your email to be public available to anyone. Just like a webpage cannot show an image from your local machine (unless it's hosted there) a CRM email cannot show an image that you copy from your local machine into the body of the email.

Here's how to work around this. You need to use pictures/logos that are publicly available. For instance, if you want to put your company logo in an email, go to your company web page, right click on the company logo and choose to copy the image. Then go to your CRM email and paste it in. The image will appear and when you send it out the image will carry through. The reason it will go through is because the reference you copy and paste points to a URL that all computers can reference and see.

If you can have a public folder that you store you images in and that can be accessed via a URL path from anywhere, then you are all set to put whatever images you want into your CRM emails. All this would take would be to add a folder to where your company website resides (maybe call it "CRMPictures") then you can manually browse to that location and copy and paste whatever pictures you want.

A little cludge of a work around but it works and it could give you a centralized place to place pictures/images to be used for your CRM Marketing needs.

Monday, 20 June 2011

Silverlight Map in CRM 2011


There are many cases in which an organization will need to work with maps as part of their Dynamics CRM experience. For example, you might be part of a courier company that needs to be able to see your customer locations in a map before you can deliver the goods. It is now very easy to create a map which you can then embed inside Dynamics CRM 2011 through Silverlight web resources.
 How to Create a Silverlight Map Control for Dynamics CRM 2011
Firstly, I’ve created a new Silverlight project inside Visual Studio and have also downloaded the Bing Maps Silverlight Control SDK. The SDK includes the required libraries which you can reference to build your own controls using a Silverlight Bing Map.
Before you can actually start building and testing your mapping application, you will need to obtain an API key for the Bing Maps Silverlight Control. You will need to insert this key into your XAML code for the map to work correctly.
<UserControl x:Class="DisplayMap.MainPage"    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"    xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"    mc:Ignorable="d"    d:DesignHeight="300" d:DesignWidth="400">
    <Grid x:Name="LayoutRoot" Background="White">        <m:Map x:Name="mymap" CredentialsProvider="<your key goes here"></m:Map>    </Grid></UserControl>
The next step is to add the map into CRM. To do this, locate the XAP file as part of the Visual Studio project. This is the file that we want to upload as our Silverlight Web Resource.
 How to Create a Silverlight Map Control for Dynamics CRM 2011
Open up CRM and navigate to Settings > Customizations> Customize the System. On the left navigation, click on Web Resources and then click on New to create a new Web Resource.
 How to Create a Silverlight Map Control for Dynamics CRM 2011
Give the new web resource a name and also select Silverlight as the type. Once this is done, save and publish your changes.
I am going to select the Account entity to hold our map control. Expand the Entities node in the customization area, select Account and then open up the main Account form.
I have created a new section on the Account form and have added the Silverlight web resource to it.
 How to Create a Silverlight Map Control for Dynamics CRM 2011
Now that it’s been added to the Account form, we just need to save and publish our changes once again. Now the map will be available for our users to view.

Creating an HTML Email in Dynamics CRM 2011

Microsoft Dynamics CRM 2011 makes bulk emailing very easy by using Mail Merge with Microsoft Word. This means you can send out newsletters to hundreds of your Dynamics CRM customers all at once, from one location. Because the Mail Merge is done within Microsoft Word, you can create full HTML emails with images and colours to reflect your company, and grab your customers’ attention.
Creating an HTML Email in Dynamics CRM 2011 
For this example we will be creating a reusable Mail Merge Template for an HTML Newsletter, so we can send frequent newsletters to our customers using the same template and theme. This template will be configured to send to Contacts, and we will set the template to pull through the Contacts first name, to personalize the email.
To create a new Mail Merge Template in Dynamics CRM 2011, navigate to SettingsTemplatesMail Merge Templates, and then click New.  Enter a Name, for example ‘Newsletter’, and set the Associated Entity, in this case we will use ‘Contact’. Click ‘Save’ and the record will be created.
Creating an HTML Email in Dynamics CRM 2011 
Next you need to create the word template file. If you have one already you can upload it at the bottom of the form, otherwise click ‘Create Template in Word’ at the top of the form to start from scratch.
Creating a new HTML Word Template
The template can be created in either an HTML editor, or simply within word itself. If you decide to use word to create the HTML template, you can use the default options such as tables, images, colours, and fonts to customize the template to look how you want. It is recommended that you use tables to colour and align your objects within your HTML email templates, as they show up best in email readers.
Creating an HTML Email in Dynamics CRM 2011 
For more complex designs, it is recommended that you use an HTML editor to create your template, such as Expression Web or Dreamweaver. This way you can customize and position objects exactly where you need them, and you can apply custom styles to your HTML.
NOTE: Make sure all CSS is embedded inline, and not called internally or externally. Also make sure to use full URL references for images and hyperlinks.
If you have created your template in an HTML editor, you can copy the whole page content when viewing the template in your internet browser, and paste it into word. You may need to change some things around to make it look right again. (It can help to change the view to web layout - click the View tab and select Web Layout in Word 2010)
Once you are happy with your template, save it as an .xml file, as something meaningful, for example ‘newsletter.xml’. You can save the template in .xml format by click FileSave As, and selecting ‘Word XML Document (*.xml)’ from the Save as type menu in Word 2010.
Creating an HTML Email in Dynamics CRM 2011 
You can now go back to your Mail Merge Template in Dynamics CRM 2011 and upload the .xml file using the ‘Browse’ button at the bottom of the form. Once selected click ‘Attach’.
Note: To make the template Organization Owned (usable by everyone) select ‘Make Available to Organization’ from the Actions menu.
To start using the template, navigate to Contacts, and select the contacts you wish to send the newsletter to (it might pay to run a test on yourself before emailing your customers). From the ‘Add’ tab, select Mail Mergeunder ‘Marketing’. In the Mail Merge window, select to start with an Organization or Personal template depending on which option you set earlier. From the lookup select the ‘Newsletter’ template. Choose whether to run the mail merge on all records, or just the ones selected, and then click OK.
 Creating an HTML Email in Dynamics CRM 2011
When the word document opens, you will need to click the CRM icon to enable the CRM add-in, which can be located under either the Mailings tab or the Add-Ins tab in Word 2010. After clicking this you will be able to see your template.
If the step by step mail merge wizard doesn’t appear automatically on the right side of the document, you can click Start Mail Merge, and select Step by Step Mail Merge Wizard from under the Mailings tab. From this wizard you can click through the steps until step 4 where you can choose to insert More Items, which will allow you to insert fields from the Dynamics CRM 2011 Contact form, such as ‘First Name’ for personalizing the emails.
Creating an HTML Email in Dynamics CRM 2011 
Note: If you want to insert Merge Fields you can resave the .xml file and upload it again to your Mail Merge Template record to save them for next time.
At this point you can update the template to contain the content and images you want added to the email. Once you have done this, and you are ready to send the email, you can click Finish & Merge from the Mailings tab, and then select Send E-mail Messages. You will be prompted to select the ‘To’ field, which is ‘E_mail’, and the subject that will be displayed in the Email messages. Leave the Mail format in HTML, and click ‘OK’ to send the emails to all records.
Creating an HTML Email in Dynamics CRM 2011 
Each email you send from the Mail Merge will be added to your Outlooks queue, and will one by one be sent from Outlook with the email account you have configured. That’s all there is to it, the emails will now be sent to your customers, and each email will be personalized with the appropriate name.
Creating an HTML Email in Dynamics CRM 2011
http://www.magnetism.co.nz/blog/paul/11-05-10/Creating_an_HTML_Email_in_Dynamics_CRM_2011.aspx
Source : 

Restrict Sales and Marketing Controls in CRM 2011


Historically in CRM 4.0 if a user wanted to have the Sales and Marketing Controls not displayed for an given user, this could not be as were by design.
Although areas would not be shown when all subareas are not visible by the security role.

It is not possible to remove the entire buttons. However, for Sales, Marketing, Service, etc... the application does contain the logic to not show a button "Area" if there are no sub-areas under it to show.
It is possible to limit visibility to a sub-area based on the security access. This is documented in the SDK and if you search for the "SiteMap XML Reference" and click on privilege, you will see the documentation on this.

More on this on how simple it is to modify the sitemap and hide areas is below:

If you put both these factors together you could limit the sub-area access for every sub-area based on privileges, then the main area buttons would go away since nothing would be visible for the user.
Do a database backup and also backup the site map first. Review the CRM 2011 "SiteMap XML Reference" before performing these actions.
1. Go to Settings > Customizations > Export Customizations/ Solutions
2. Choose Site Map from the list and click Export Selected Customizations.
3. Make sure to save a copy of the Site Map before making any changes.
4. Open up the site map and search for text that begins <Area ID="MA" ResourceId=Area_Marketing" and ends with </Area> remove the entities (sub-areas) the visible entities like account and contact from this area.
5. Save this as your edited site map.
6. Go to Settings > Customizations > Import Customizations.
7. Browse to your edited site map and import it into CRM.
8. Publish your customizations.