Wednesday 20 June 2012

Promote to Campaign Response button is disabled in CRM Outlook - Tips & Tricks

Hi everyone,

I just wanna quick update a trick to overcome the problem when your "Promote to Campaign Response" button in CRM outlook is disabled.

The scenario here is: you send out an email to a customer via CRM Outlook. Then the customer replies and you want to convert the replied email to a campaign response (even originally the out-going email is not a part of any campaign).

Here is what will happen:

You can click "Track in CRM" button to track the replied email as below:


But when you click "View in CRM", on the email form, the "Promote to Response" is disabled
as below:


The reason for this is:  the email activity needs to be a campaign activity (belongs to a campaign).

So solve the problem, very simple. You go back and "Set Regarding" the replied email to any campaign activity you have in CRM as below:


So now the button is enabled for you to convert into campagin response ! Bingo !

Note: Sometimes, there will be another reasons that could make the "Promote to Response" button disabled also. For example, the person who want to promote an activity to a response need to be the person owns that activity at the first time. Or your CRM Settings lacks of some required features. To ensure everything is correct, you could read this article to learn 4 ways to use "Campaign Response" in CRM : http://rc.crm.dynamics.com/rc/2011/en-us/on-prem/5.0/campaignresponses.aspx 

If you have any problem with it, please email me at linhhk87@gmail.com. Im willing to discuss ;)

Kelly

Friday 15 June 2012

CRM 2011 Online Authentication for Custom Web application

Hi everyone,

Long time no post.

Today I would like to show you guys how to authentication CRM 2011 Online in coding .Net C#.
The objective is: creating a custom web application capturing contact information, then updating the information into CRM Online.

For CRM On Premise, to do so, you guys could follow exactly the same to this blog: http://blogs.msdn.com/b/crminthefield/archive/2011/06/03/microsoft-dynamics-crm-2011-custom-contact-entry-website-using-early-bound-entity-classes.aspx

However, in order to connect to CRM 2011 Online using IOrganizationService Web Service, you need to change the code a bit to make the authentication through (Remember, CRM On Premise using AD authentication, but CRM Online using Windows Live ID to do that).

So please, following the above blog until the code inside and using the below code for CRM Online Authentication:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.ServiceModel.Description;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Crm;
using Microsoft.Crm.Tools;
using System.Net;
using Microsoft.Xrm.Sdk;
using Microsoft.Crm.Services.Utility;
namespace CRM_Test2
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        private static ClientCredentials GetDeviceCredentials()
        {
            return Microsoft.Crm.Services.Utility.DeviceIdManager.LoadOrRegisterDevice();
        }


        protected void Button1_Click(object sender, EventArgs e)
        {
            //Authenticate using credentials of the logged in user;
            string UserName = "abc@hotmail.sg";   //your Windows Live ID
            string Password = "crmadmin@123";    // your password
            ClientCredentials Credentials = new ClientCredentials();
            Credentials.UserName.UserName = UserName;
            Credentials.UserName.Password = Password;
     
            Credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
            //This URL needs to be updated to match the servername and Organization for the environment.
            Uri OrganizationUri = new Uri("https://<CRM-Online-Server-Name>/XRMServices/2011/Organization.svc");           //this URL could copy from Setting --> Developer Source
         
           Uri HomeRealmUri = null;
            //OrganizationServiceProxy serviceProxy;  
            using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, GetDeviceCredentials()))
           
           {
                IOrganizationService service = (IOrganizationService)serviceProxy;
          
            //Instantiate the contact object and populate the attributes.                     
            Contact contact = new Contact();
            contact.FirstName = txtFirstName.Text.ToString();
            contact.LastName = txtLastName.Text.ToString();
            contact.EMailAddress1 = txtEmailAddress.Text.ToString();
            Guid newContactId = service.Create(contact);           
         
            //This code will clear the textboxes after the contact is created.
            txtFirstName.Text = "";
            txtLastName.Text = "";
            txtEmailAddress.Text = "";
            txtPhoneNumber.Text = "";

            }
        }
       
    }
}

Notice the red lines in above code. That's the difference between authenticate in CRM Online and On Premise. For Online version, you need to call the function named "GetDeviceCredentials()", which is defined as private function before that. In order to use this function, you MUST to add one more item which is from SDK --> SampleCode --> Cs --> deviceidmanager.cs. So add this new item into your solution.

After adding the deviceidmanager.cs item, open the cs file and add one more nesscessary reference for using the item, which is: System.Security.Cryptography.

Then now build the whole solution ! Everything is done !

Any question or unclear point. Please drop me an email at linhhk87@gmail.com. I will reply you very quick ;)

Have a nice weekend ;)