Muhammad Ali Khan

MS CRM 3.0, MS CRM 4.0, Sharepoint 2007 & Sharepoint 2010

Archive for the ‘MS CRM 4.0’ Category

Auto Refresh Marketing List In MS CRM 4 Using Workflow

Posted by Ali Khan on February 21, 2010

Creating Marketing List & Campaign is one of the common tasks in MS CRM. With dynamic nature of the data, members of the marketing list may change daily, weekly or monthly and hence they need to be re-evaluated frequently.

MS CRM 4 supports evaluating, adding, removing members from a marketing list even if the list is in a running campaign (unless the list is locked), but unfortunately these operation have to be pre-form manually, there is no such feature as “Auto Refresh Marketing List” on daily or weekly or monthly basis.

With above requirement in mind, I have create a simple workflow that can run daily on a marketing list and evaluates whether the new members have to be added to the list or some existing member has to be removed from the list since it now longer matches the criteria for which the list was created.

I have created two workflows for this purpose:-

My First workflow, “Auto Refresh Marketing List” takes two parameters and refreshes the marketing list on which it is run. These parameters actually define the criteria of the marketing list members. These parameters are:-

Parameter Name Value Direction
UserQueryID A Guid of User View (userquery), In case you want to refresh the marketing list against a particular user defined view. Input
FetchXml If you don’t have the view id and you have the fetchxml, you can specify in this parameter. Input

 

My Second workflow “Get Next Day” is a simple workflow that returns me the workflow next run date and it will help me in running my workflow daily.

Parameter Name Value Direction
InitialDate Set to the last Refresh Date Input
NextDate InitialDate + 1, Returns the Next Date on which the workflow should run Output

 

To refresh/evaulate any marketing list members, I used the “QualifyMemberListRequest” Request from “MS CRM Sdk”. The code logic is pretty straight forward.

a) Fetch all the members that matches the View (UserQueryID) or the FetchXml.

b) Use the “QualifyMemberListRequest” to qualify (add or remove) the marketing list members.

Here is the sample code. You can download the full code (with support for account, contact, lead list and FetchXml) from here: – Download Source Code

image

Setup the Refresh Marketing List Workflow:-

1) Download the code and register the assembly using the “MS CRM Plugin Registration Tool”.

2) You can also export the workflow and the list customization from the “customization.xml” attached.

image

Or you can follow the steps below.

3) Create a variable “RefreshDate” of type “DateTime” in the entity “list”, as show below

image

4) Create a new workflow name it “Auto Refresh Marketing List” on the “list” entity. I configured my workflow to run on “On Demand” and on the change of the attribute “Refresh Date” as shown below.

image

image

5) Now here is the logic of the workflow

·         NextDate = “Get Next Day”(workflow)

·         If Marketing List. RefreshDate Contains Data then

                Timeout Until MarketingList.RefreshDate then

                                Run “Auto Refresh Marketing List(workflow)

·         Update MarketingList. RefereshDate = NextDate

 

6) Here is how i configure it.

a. Clickclip_image002[3], and then go to “My Custom Workflows” è “Get Next Day” and add this workflow activity.

b. Configure the input parameter (InitialDate) for the workflow “GetNextDay” as shown below.

image

c. Now click “Add Step” and this time click “Add Condition”, click on “click to configure conditon” , to configure the following condition as shown below.

image

d. Now add a “Wait Condition”, and click on “click to configure condition”, to configure the wait until “RefreshDate” as shown below.

image

e. Click on the “Select this row and add step” and the click on “Add Step” and add this time add the “Auto Refresh Marketing List”. “MyCustom Workflows” ==> “Auto Refresh Marketing List”. Now configure the parameters as show below, you can either specify the “View ID” or you can specify the “Fetchxml”. Note, I have specified a hard coded “ViewID” but this value can come from any dynamic variable from the list entity.

image

f. Final step, add a new step “Update Record” to update the “RefreshDate” of the “list” entity, as shown below. Note: – I added the “RefreshDate” on the main form (for debugging purpose only), but better NOT to add it on the main form and update it on the “Additonal Fields” tab. This will avoid triggering of the workflow accidently from the user if he changes the “RefreshDate” on the main form in the application.

image

g. Now publish the workflow, it should look like this now.

image

7) Now create a test list, and apply the workflow as shown below, it will refresh the list automatically. Update the “RefreshDate” and will launch another instance of “Auto Refresh marketing list” that will wait unit the “RefreshDate” happens, i.e. Tomorrow.

image

image

image

image

8) Here is my custom view.

image

9) Finally, you can download the “Source Code”, the customized “List form” and the “workflow template”, from here (Download)

Note: – If you have difficulty in writing “FetchXml”, use this tool “Fetch Xml Builder” to generate the FetchXml for you.

That’s all folks.

Advertisements

Posted in MS CRM 4 Workflows, MS CRM 4.0 | Tagged: , , | 5 Comments »

Close Service Activity On Create Message In PlugIn

Posted by Ali Khan on February 19, 2010

Here is a simple code to close the service activity in a MS CRM Plugin.

  1: SetStateServiceAppointmentRequest req = new SetStateServiceAppointmentRequest();
  2: req.ServiceAppointmentState = ServiceAppointmentState.Closed;
  3: req.ServiceAppointmentStatus = 8;
  4: req.EntityId = new Guid(context.OutputParameters["id"].ToString());
  5: SetStateServiceAppointmentResponse resp = (SetStateServiceAppointmentResponse)crmService.Execute(req);

But the above code will work perfectly only if the message is Post Update but doesn’t work if the message is Post Create means it doesn’t close the service activity. Strangely, it doesn’t give any error as well. To add to my surprise, if you had configure any plugin on “SetState” or “SetStateDynamic” for serviceappointment even those plugin will be trigger, but the state of the service activity will not change. Why?, i am not sure.

But does this means we cannot close service activity on the “Create” message?, well the trick is to register the above plug-in as Asynchronous mode (as shown below). now the above message will Close the Service Activity even on the Create Message.

image

Posted in MS CRM 4.0, MS CRM Plugin | Tagged: | 2 Comments »

Show The Associated View On CRM Entity Load

Posted by Ali Khan on February 16, 2010

Hello, Today i just want to share a small MS CRM JavaScript. As we know once any MS CRM Entity form load, the default view is the “Information” view of the entity, as see below for my account form.

image

What if i want to “Quotes” grid to appear as soon as the Account form is open. Well its really one line of JavaScript (First find the id of the left navigation node, thanks to the IE8, it is very easy now, press F12 to launch the debugger tools, find the element by “Search element by Click” option and there you have the element id as shown below)

image

So here is the script for the form OnLoad() event.

  1: if(crmForm.FormType == 2)
  2: {
  3:   document.getElementById('navQuotes').click();
  4:   document.getElementById('_NA_Info').click();
  5: }

and here is how my “Account” form once it loads( i also collapsed the “Details Node” for better view ability). Now once i double click any account in my main grid, by defaults, it loads the “Associated Quotes View” of the “Account”.

image

That’s all.

Posted in MS CRM 3.0, MS CRM 4.0 | Tagged: | 1 Comment »

Relating/Connecting MS CRM 4.0 Data With Custom External Content Type Data In SharePoint 2010

Posted by Ali Khan on February 4, 2010

In this post, i will first display the data from MS CRM 4.0 and from my custom external type(SQL Server Database) in my SharePoint 2010 portal and then show you how to relate(connect) these two different external content type. I got this idea from the “Fabain Williams SharePoint” blog from here SharePoint 2010 Business Connectivity Services Teaser with Multiple External Content Types surfacing in One External List.

As i saw the above post, i thought i could use it to solve my old problem in SharePoint 2007 :). I remember last year one of my customer asked me to display and relate the data from MS CRM 4 and Axapta on SharePoint portal and i end up writing my own custom Web part, since there exits no relationship between these two external content type in MOSS 2007.

Note:- There exits NO PHYSICAL RELATIONSHIP between the two external content type i am going to use below. So here we go:-

Step 1: Setup the MS CRM Account External Content Type:-

First i have to setup my external content type to fetch data from MS CRM 4. I already did that in one of my earlier post. You can see the complete post here (Using Business Connectivity Services(BCS) In SharePoint 2010 For Connecting To MS CRM 4.0). Here is how MS CRM Accounts look like. (The important field to note here is the “AccountNumber” since we will be relating the two external content type on this column).

image

Step 2: Setup the Other External Content Type(SQL Server Database):-

I then created another “External Content Type”, this time to a SQL Server Database, for this you can use this post from Microsoft (How to: Create an External Content Type Based on a SQL Server Table).

Here is how my table(CompanyProjects) in custom database look like. This tables contains the list of the projects against a particular MS CRM Account. As you can see i have put the AccountNumber field in both “MS CRM External Content Type” (above) and in my custom (CompanyProjects) table below, since we will be relating(connecting) the data from these two different source on this field.

image

and here is the data i manually put in.

image

The next step is to create the external content type for the above table( you can do it by following the steps here How to: Create an External Content Type Based on a SQL Server Table). And then i created a SharePoint 2010 List for this external content type, see below. (The important field to note here is the “AccountNumber” since we will be relating the two external content type on this column).

image

Step 3:- Create the “Site Page” which will host these two external content type:-

Go to Site Actions ==> New Page. A New Page Dialog will popup. Name the page and click create.

image

It will open the page in the design mode, now we will insert our two external content type. Click on the “Insert” ribbon, and then click on the “Existing List” button. Select “MS CRM Accounts” list and then click add.

image

image

Here is it how it looks like now. (Note by default the view of the WebPart will be show only the BDC Identity, Edit the WebPart and select the view to your desired view). Note the “AccountNumber” in the below view.

image

Similarly, click on the add “Existing List” button and add the “My Custom Projects” list this time. The whole page will now look like this. Note again the “AccountNumber” in the list.

image

As you can see, both our MS CRM Account and our other external content type (Projects) are on the page now, showing the complete data from both the list. Now the final step is to relate/connect these two lists.

Step 4:- Relate/Connect the Two External Content Type:-

In the SharePoint 2010 portal, Click “Page” ribbon and then from the “Edit” dropdown, select “Edit in SharePoint 2010” Designer, this will open the page in “SharePoint 2010” designer.

Once in SharePoint 2010 designer, select the “MS CRM Account” web part and click “Add Connection” in the ribbon.

image

Now we will create the relationship (well its not really a relationship, its just a connection) between the two WebParts below. A wizard will startup, here is the step by step process to create this connection.

image

image

image

image

Make sure you select the correct columns while defining this connect from both list (i.e. AccountNumber)

A connection between two webparts is now setup. Save the Page in SharePoint 2010 designer, and the open the page in the browser. Here is how the page now looks like. Click on any MS CRM Account Row (Click on image ICON to select the row)

image

image

You can see now the “Project List” is now filtered on the MS CRM Account you selected from the above List (Based on the “Account Number”).

All i can say “Coooooool”. i remembered i had to write a custom WebPart for this to happen in SharePoint 2007.

Actually, i didn’t stop here :), in fact i created one more relationship between my “Custom Projects” and the details of the Tasks “Task List”. so my projects will be filtered on the selected “MS CRM Account” and then my “Tasks” list will be filtered on my selected “Custom Project”. Here is how it looks like. (i am sure you can follow and repeat the above steps to achieve this).

image

So the connection between MS CRM Account and Custom Project is on “AccountNumber” and the connection between “Custom Project” and “Task List” is on “ProjectId”.

Finally, does it means, we don’t have to create our own WebPart for displaying related data from two different “External Content Type”. Well off course not, SharePoint 2010 does provide you a very good platform for connecting non-related “External Content Type” with features of sorting, filtering, creating custom views with basically no code. But there may still exits scenarios where you have to create your own WebPart.

That’s all for now.

Posted in BCS, Bussiness Connectivity Services, MS CRM 3.0, MS CRM 4.0, Sharepoint 2010, SharePoint 2010 Designer, Sharepoint Foundation 2010 | Tagged: | 3 Comments »

Using Business Connectivity Services(BCS) In SharePoint 2010 For Connecting To MS CRM 4.0

Posted by Ali Khan on January 24, 2010

In this post i will create a custom BCS .net connector (for SharePoint 2010) in Visual Studio 2010  to connect to MS CRM 4.0 and perform the basic CRUD(Create, Retrieve, Update, Delete) operations on the MS CRM “Account” Entity.

Source Code:- You can Download the Source Code of this Project From Here, Source Code.

Step 1:- Create a Custom .Net BCS Project In VS2010 For MS CRM 4.0

As First Step, Open VS 2010 (Beta 2 Ultimate Edition), Go to File==>New==>SharePoint 2010 ==> Business Data Connectivity Model Project.

Since VS2010 has the built in support for editing the application definition file, it will give me a nice GUI BDC Editor, After renaming the default “Entity1” and adding CRUD methods, it will look like this.

image

You can use the “BDC Method Details” window (the 2nd window in the above diagram) to create new Methods, as shown in the diagram below.

image

There is also the BDC Explorer on the right side. You can use the BDC Explorer to create “Methods In & Return Parameters” Here is how it look like.

image

Simply right click on the parameter name and click on “Add Type Descriptor” and then you can define the “Account” entity, as shown below.

image

If you want to use the VS2010 BDC Editor, Here is a good article as a starting point on how to use the editor (Building a BDC Model using the .NET Assembly Connector). But i personally like the XML Editor more as i find more flexibility in it. So to open the XML Editor, Right Click on your Model File (MSCRMBdcModel.bdcm) in “Solution Explorer” and click “Open With” a “XML Editor”  to bring the Model XML Editor.

image

Here is how it looks like.

image

And here is our “Account.cs” Entity.

image

And the Implementation of all the “CRUD” Methods from MS CRM 4.0 in “AccountService.cs”

image

Now from the Solution Explorer, right click and click “Deploy”, it will package the solution and deploy the External BCS Content Type on the your SharePoint 2010 site. (Remember to change the SharePoint site URL in the project properties window)

image 

This is how it looks like in the “Central Administration”. you can configure permission on it by click on the drop-down menu and select “Permission”.

image

Step 2:- Configure External Content Type Profile Page In Centeral Administration

Now go to Central Administration ==> Application Management ==> Service Application ==> Business Data Connectivity and click “Manage” from the top Ribbon. You will see the screen below,

image

Click “Edit” from the Ribbon and select “Configure” to configure the path for the “Profile Page” and click ok. See the diagram below.

image

Generate the profile page for the External Content Type “Account” by click on the dropdown ==> “Create/Upgrade Profile Page”.

image

So Now if you browse to any MS CRM Account with the above URL (e.g. http://win-1r2gn7r1jaq:8000/_bdc/MSCRMBdcModel_BdcModel1/Account_1.aspx?AccountID={ADE922F4-6C06-DF11-BF5A-001E8CFDD686}), you will get a profile page for the MS CRM Account as shown below.

image

Step 3:- Create a “External Content Type” List To Host MS CRM 4.0 Account

Browse to the site, where you deploy the solution, go to Site Actions==> More Options ==> List ==> “External List” ==> Create. Here Select the “External Content type”, as show below, and click “Create”.

image

Now the list will shows all the accounts from MS CRM 4.0, as shown below.

image

Off course you can always change the List View and remove the “AccountID”, as it is a Guid and there is no point in showing it to the end user. Here is how it looks like now.

image 

Step 4:-  Using SharePoint 2010 Designer to Create the “New”, Edit Form for our External Content Type

If you click on “Add new Item” now, it will throw an error because the create and edit page doesn’t exit for the list. So lets create the “New” & “Edit” form for our list in SharePoint 2010 Designer.

Open your site in SharePoint 2010 Designer ==> List and Libraries ==> click “CRM Accounts” (Your external list) to see the diagram below.

image

As you can see there are now “Create” and “Edit” Forms in the “Forms section”. So click “New” in the form section to open up the dialog box as shown below (for the “Create Account”) and click ok.

image

Do the same for the “Edit Account”, but this time select “Edit item form”, your forms section will now look like this.

image

Now click on the “EditAccount.aspx” page and modify the view. Here in SharePoint 2010 Designer, you can decide which field to show and which one to hide from the end user. Here is how the “EditAccount.aspx” looks like in SharePoint 2010 Designer (after editing). As you can see we have deliberately hide the “Account ID” (a Guid) and Parent Account (A MS-CRM Lookup) on the Edit Form.

image

Save the forms. Now browse to your list (MS CRM Accounts) in the SharePoint site. Here is how the “Create Account” looks like.

image

And Here is “Edit Account” and “Delete” option. You can see below the “Account ID” and “Parent Account” are not visible as we removed these field in the SharePoint 2010 Designer.

image

Oh Yes, and here is how it looks like in MS CRM 4.0

image

With this example, now you can perform all the basic operations CRUD( Create, Retrieve, Update, Delete) on MS CRM Account inside your SharePoint 2010 Portal, thus opening new opportunities for integration between MS CRM 4.0 and SharePoint 2010 Portal.

That’s all folks.

Posted in BCS, Bussiness Connectivity Services, MS CRM 4.0, Sharepoint 2010, SharePoint 2010 Designer, Sharepoint Foundation 2010 | Tagged: , | 13 Comments »

Add More Values to Duration(Drop-Down) In MS-CRM 4.0 Task Entity

Posted by Ali Khan on January 24, 2010

In this small post, i will show you how to add more options(Values) to the Standard “Duration” drop-down in the “Task” Entity. So, out of the box, the “Duration” field on the “Task” entity look like this.

image

Note:- “Duration” Field is not a MS CRM Pick-List. It is editable and user can add anything e.g. “4 Days”, “52 Minutes” etc. In fact the data type of the “Duration” field is “Integer”. but in Task entity it looks like a Standard MS CRM Pick list. In-Background MS CRM is generating a table for this field and displaying the values in the drop-down. See the attribute description below:-

image

So to add more values to the “Duration” drop-down, put the following JavaScript code in the Task Entity Form ==> OnLoad() event, save the form and publish the “Task” entity. The code is simply adding rows to the table, which is used to display the “Duration” drop-down on “Task” Entity Form.

var obj = document.getElementById('actualdurationminutesSelect');
var tbl = obj.childNodes[1];
var lastRow = tbl.rows.length;
var row = tbl.insertRow(lastRow);
var cell = row.insertCell(0);
cell.val = '4 days';
cell.innerText = '4 days';
lastRow++;
row = tbl.insertRow(lastRow);
var cell = row.insertCell(0);
cell.val = '5 days';
cell.innerText = '5 days';

After publishing the “Task” entity, the “Duration” drop-down now look like this, with values “4 days” & “5 days” coming inside the default drop-down.

 image

That’s all folks !!!

Posted in MS CRM 3.0, MS CRM 4.0 | Tagged: | 3 Comments »

Update Rollup 8 for Microsoft Dynamics CRM 4.0 is available

Posted by Ali Khan on January 21, 2010

INTRODUCTION

Update Rollup 8 for Microsoft Dynamics CRM 4.0 is available. This article describes the hotfixes and the updates that are included in this update rollup. This update rollup is available for all languages that are supported by Microsoft Dynamics CRM 4.0.

MORE INFORMATION

The build number of the update rollup packages for the Microsoft Dynamics CRM 4.0 server, for the Microsoft Dynamics CRM 4.0 client for Microsoft Office Outlook, and for the Microsoft Dynamics CRM 4.0 E-mail Router is 04.00.7333.2542.
The file names for the 32-bit versions of the update rollup packages are as follows:

  • CRMv4.0-KB975995-i386-Server-LangID.exe
  • CRMv4.0-KB975995-i386-Client-LangID.exe
  • CRMv4.0-KB975995-i386-Router-LangID.exe
  • CRMv4.0-KB975995-i386-DMClient-LangID.exe
  • CRMv4.0-KB975995-i386-SRS-LangID.exe
  • CRMv4.0-KB975995-i386-MUI-LangID.exe

The file names for the 64-bit versions of the update rollup packages for the Microsoft Dynamics CRM 4.0 server and for the Microsoft Dynamics CRM 4.0 E-mail Router are as follows:

  • CRMv4.0-KB9759952-amd64-Server-LangID.exe
  • CRMv4.0-KB975995-amd64-Router-LangID.exe
  • CRMv4.0-KB975995-amd64-SRS-LangID.exe
  • CRMv4.0-KB975995-amd64-MUI-LangID.exe

Source:- Rollup 8 Microsoft CRM

Posted in MS CRM 4.0 | 1 Comment »

Download Latest Microsoft Dynamics CRM 4.0 Software Development Kit (SDK)

Posted by Ali Khan on November 26, 2009

Quick Details
File Name: CrmSdk4.exe
Version: 4.0.11
Date Published: 11/24/2009

Overview

The Microsoft Dynamics CRM 4.0 Software Development Kit (SDK) is for developers, system customizers, and report writers. This SDK documentation contains information for developers writing server side code, custom business logic, integration modules, workflow assemblies, and plug-ins. It provides an architectural overview of Microsoft Dynamics CRM, the entity model, security model, and Web services. Sample code and walkthroughs are provided to guide you through the new features. It also contains information for developers customizing the Web client or Microsoft Dynamics CRM for Microsoft Office Outlook, including scripting, integration of custom Web pages, sample code, and a detailed user interface style guide.

In addition to the documentation, this download package includes the projects for all sample code found in the documentation, and full featured samples that are not included in the documentation. The package includes a visual style guide you can use to make your customizations fit in smoothly, and a style sheet you can use as a basis for your work. There are also tools and helper code provided in this package. Look for regular updates to this SDK!

November 10, 2009 – Updated the assemblies in the Bin folder. Use these updated assemblies instead of the ones in the previous release of SDK 4.0.10.

For More details see here…

Posted in MS CRM 4.0 | 3 Comments »

IE8 with debugging tools for MS CRM 4.0

Posted by Ali Khan on August 10, 2009

Source : From MSDN Blog site for MS CRM

The Microsoft product team also released the following statement regarding support for CRM 4.

“We’re thrilled to have IE8 in market and released. During the past 12 months we have worked closely with the IE team and Dynamics CRM has been one of the key “test products” for the IE team when working through their validation and tests. During the process we naturally identified issues and resolution to those were vigorously pursued and implemented. At this point we only have 1 known issue and we’re happy to be able to state that IE8 is an officially supporter browser for Dynamics CRM 4.0. We expect the Implementation Guide to be updated in April 2009 to reflect this supported status for IE8.”
Preety Cool…

For more details IE8 For MS CRM 4 Developers

Posted in MS CRM 4.0 | Leave a Comment »

U2U Article: A Microsoft SharePoint 2007 custom field type for Microsoft CRM Dynamics 4.0

Posted by Ali Khan on August 9, 2009

I found this great post on U2U articles for integeration between ms crm and sharepoint , and decided to share with you.

Source : U2U
For details go to the article URL.
Custom Field Type For MS CRM 4.0


Posted in MS CRM 4.0, Sharepoint 2007 | Leave a Comment »