Archive

Archive for January, 2010

Microsoft Dynamics CRM and sample code: Think First

January 11, 2010 Leave a comment

Here’s one of my favorite samples floating around in the CRM world:

         image

I have seen this code numerous times and before explaining what’s wrong (actually everything is wrong, besides the alerts), I want to tell you a story, which is also told by the above code.

You enter a mall and buy a basket, because you want to see if there is an apple in it. However, after leaving the mall you throw the basket away without using it. Back at home you search for an existing basket, take the first apple out of it and try to figure out if it is red. You then wonder why you cannot determine the color, because you forgot to check if there was a basket at all.

That’s what the code does!

  1. There is no reason to initialize the lookup variable with a new Array when setting it to null in the next line. This is the basket you are buying and instantly throwing away.
  2. Even setting it to null is nonsense when setting it to crmForm.all.customerid.DataValue afterwards.
  3. The DataValue property is null if no value is stored in a lookup field. Therefore accessing lookup[0] results in a null reference exception if DataValue equals null, because the lookup variable then will be null as well. It is the same as grabbing the first apple from a basket without having the basket first.
  4. If there is a value stored in the lookup field, then lookup[0] won’t be null. The only way it could be null is you setting it to null in code (crmForm.all.customerid.DataValue[0] = null), but that would be like writing var circle = null and wondering why circle.radius doesn’t work.

To summarize: samples are great. But be sure to understand what they do first.

Cheers,

Michael Höhne

Simplify your life with JavistaCRM

CRM for iPhone

Download JavistaCRM on iPhone v1.5

Start your trial experience of JavistaCRM

FAQ concerning JavistaCRM

Question, Feedback or to be a partner

Advertisements

Microsoft Dynamics CRM – Advanced Workflows

January 11, 2010 Leave a comment

Microsoft Dynamics CRM provides very powerful workflow designer tools to create workflows for various business scenarios. Waiting workflows are one of them. Very often, it is required to create waiting workflow on dates. So if a date is changed the waiting workflow remains in waiting state and date change executes another waiting workflow. So this aggregation of workflows affects CRM Server performance and application functionality.

Recently I created a custom workflow activity to stop these waiting workflows in a recursive workflow. So I would like to share my experience with all of you.

I am in a condition to create a waiting workflow to reschedule my activity periodically such as in recurring appointments, Auto Reorder (Sales Order), etc. My workflow is fired on Create of activity/Order and on change of Next Due date/Next Order Date. So if the user has changed Next Due Date or Next Order Date, the workflows in waiting remains in waiting and also a new Waiting workflow is fired. My aim is to stop the existing workflow as it is invalid now and start a new waiting workflow with updated information.

My workflow name is Auto Reschedule Activity. Here is the description of my workflow:

Start:

    Wait for Next Due Date == Today

         Reschedule Activity Accordingly

         Recursive Call: Auto Reschedule Activity

End

What i am looking for is:

Start:

     Check if there is an existing workflow with same Workflow ID, Entity ID and in Waiting State.

          Then Kill that workflow.

     Wait for Next Due Date == Today

          Reschedule Activity Accordingly

          Recursive Call: Auto Reschedule Activity

End

So I started with a custom Activity to fetch workflows in waiting state with same name and regardingobjectid:

I created a query object in my custom workflow activity:

QueryExpression query = new QueryExpression();

query.EntityName = “asyncoperation”; 

query.ColumnSet = cols;

And created 3 conditions as below:

ConditionExpression c1 = new ConditionExpression();

c1.AttributeName = “name”;

c1.Operator = ConditionOperator.Equal;

c1.Values = new Object[] {‘My workflow Name’}; //Workflow

ConditionExpression c2 = new ConditionExpression();

C2.AttributeName = “statecode”;

C2.Operator = ConditionOperator.Equal;

C2.Values = new Object[] {1}; //Waiting

ConditionExpression c3 = new ConditionExpression();

C3.AttributeName = “regadingobjectid”;

C3.Operator = ConditionOperator.Equal;

C3.Values = new Object[] {context. PrimaryEntityId}; //Waiting

Now I have all the waiting workflows regarding my activity. Ideally there will be only one workflow in waiting state all the time. This workflow will be responsible for rescheduling.

Now is the time to kill the outdated workflow. Use code like this for setting that workflow to complete/cancelled.

foreach (BusinessEntity be in bec.BusinessEntities)

{

asyncoperation async = (asyncoperation)be;

async.statecode = new AsyncOperationStateInfo();

async.statecode.Value = AsyncOperationState.Completed;

service.Update(async);

}

Note that you can improve this workflow utility to add lot more functionality to the workflow designer. Workflow is also described in the Microsoft Dynamics CRM SDK.

Cheers,

Ayaz Ahmad

Simplify your life with JavistaCRM

CRM for iPhone

Download JavistaCRM on iPhone v1.5

Start your trial experience of JavistaCRM

FAQ concerning JavistaCRM

Question, Feedback or to be a partner

Accelerators: Microsoft Ties Dynamics CRM to Twitter

January 11, 2010 Leave a comment

Accelerators: Microsoft Ties Dynamics CRM to Twitter

image When it comes to Microsoft Dynamics CRM Accelerators, sometimes it’s hard to keep up with the new stuff. The accelerator program is conducted by people who love the CRM product. From the CodePlex site we learn:

CRM Accelerators are a range of add-on solutions developed for Microsoft Dynamics CRM 4.0 customers and partners. Each accelerator is available at no cost and will showcase how the Microsoft Dynamics CRM 4.0 platform can be configured and extended to broaden marketing, sales and service capabilities. Microsoft Dynamics CRM customers and partners are encouraged to further extend these accelerators to meet their specific business needs. Each accelerator will be fully supported as per any other customization for Microsoft Dynamics CRM that follows SDK guidelines. Additionally, all samples are supplied with full source-code so they can be extended further to meet specific customer requirements.

This summer one of the more interesting Accelerators was highlighted on About.com’s Computing Center:

“Microsoft has integrated its Dynamics CRM (customer relationship management) software with Twitter, in just the latest move by an enterprise software company to latch onto the wildly popular micro-blogging service.

The social-networking accelerator — part of three new add-on modules Microsoft is releasing for Dynamics CRM — culls and catalogs relevant Twitter messages, such as a discussion about the Dynamics user’s company, and provides various analytic tools.

The integration, announced Thursday, is also meant to help Dynamics users boost their sales databases. Twitter usernames can be converted into a Dynamics CRM customer record or sales lead, to which more data, such as a phone number, can be added over time.”

Read more…

The latest news:

     – November 6 2009: Interim set of updated SQL 2005 Dashboards released for Analytics Accelerator R2, please review and provide feedback!

     – October 19 2009: Social Networking accelerator has been released!

     – October 13 2009: Portal Integration and Partner Relationship Management accelerators have been released!

Enjoy,

JaAG

Simplify your life with JavistaCRM

CRM for iPhone

Download JavistaCRM on iPhone v1.5

Start your trial experience of JavistaCRM

FAQ concerning JavistaCRM

Question, Feedback or to be a partner

Data Integration/Migration using SQL Integration Services (SSIS) 2008

January 4, 2010 2 comments

I wrote a blog article last year on how to integrate Microsoft Dynamics CRM using SQL Integration Service (SSIS) 2005 (http://tiny.cc/BQiiR) . I hope that article provided you with an alternative solution for your integration/data migration project with CRM. Due to the limited capabilities in SSIS 2005 with CRM web services, we created a proxy class as a work around to provide easy access to the CRM API.

With the new release of SQL server 2008, there were few improvements that simplify the integration of SSIS and CRM. It does not require you to create the proxy class anymore since SSIS 2008 allows you to add web references within the script component object. It also allows you to code in the language that I like the most, C#.

Here I would like to share how to leverage SSIS 2008 to integrate with CRM without the proxy class so that you can use it on your next CRM data integration/migration project.

Before we get started, here’s the list of requirements:

  • SQL Server 2008 Standard/Enterprise Edition with SQL Integration Service Installed
  • Microsoft Dynamics CRM 4.0
  • Visual Studio 2008 Professional Edition SP 1 with Business Intelligence Tools Installed
  • CRM SDK and C# knowledge

In this blog, I will use an example to show you how to send contact data stored in an Excel document to MSCRM 4.0 via CRM Web Services using SSIS.

Source Data

Source data is data from the other system that you would like to send to the CRM system. Your source data can be a text file, a database, etc… Since we often use Excel to collect our information, I will use a simple Excel document as my source data for this blog article.

Source Data: Excel Spread Sheet

image

Create SSIS Package

Launch Visual Studio 2008 to start a New Integration Services Project

After creating the project, follow the steps below to set up the SSIS package.

– Rename Package.dtsx to Contact.dtsx

Add Control Flow Items

Drag and drop a “Data Flow Task” from the Toolbox to the Control Flow Design Pane.

image

Add Data Flow Items

Double click on the Data Flow Task item that you just added and it will take you to the Data Flow Design Pane. Here we will specify the source data and also to write script to send data to CRM.

Specify Source Data

– Since our source data is an Excel document, drag and drop the Excel Source from the Toolbox to the design pane.

– Double click Excel Source to open the Excel Source Editor.

– Click New… button to open the Excel Connection Manager to specify the Excel file path, and then click OK.

image

– Select “Table or View” from Data access mode dropdown box.

– Select “Sheet1$” from Name of the Excel sheet dropdown box.

– Click OK to close the Excel Source Editor window.

Setup Script Component

– Drag and Drop Script Component to the design pane.

– Select Transformation and then click OK.

– Connect the two shapes by dragging the green arrow from Excel Source to Script Component.

– Double click the script component to open up the Script Transformation Editor.

– Select the columns that you would like to send to MSCRM from the Input Column window. In this example, I selected First Name, Last Name, Phone and Email Address.

– Remove Output in the Inputs and Outputs section since we are not going to output anything in this example.

– Click on the Script tab, click on Edit Script button. The Visual Studio window should open.

image

Add CRM Services

Since SSIS 2008 allows you to add web references in the Script Component, we will add the two web service references in this step. Please be aware that you must save the script component project by clicking the Save button on the toolbar after you added the CRM web references, otherwise the web references will not load next time you reopen the script component.

– Right click on the project in the Project Explorer window.

– Select Add Web Reference… from the menu.

image

– Repeat the steps above to add the CRM metadata service if necessary.

Coding the Package

In order to use the web reference in our code, we need to include the CrmSdk web reference to the script component project. To get the script component namespace, right click on the project and select Properties… from the menu. The namespace is in the Default namespace textbox. In this example, my script component name space is SC_ad0e4b91cb7e48cdb8fa2d240e3e5c30.csproj.

image

I added the following statement to my project.

using SC_ad0e4b91cb7e48cdb8fa2d240e3e5c30.csproj.CrmSdk;

Lastly, copy and paste the following code to the ScriptMain section:

private CrmService service = null;

    public override void PreExecute()
    {
        base.PreExecute();

        CrmAuthenticationToken token = new CrmAuthenticationToken();
        token.AuthenticationType = 0;
        token.OrganizationName = "AdventureWorkCycles";

        service = new CrmService();
        service.Url = "http://localhost/mscrmservices/2007/crmservice.asmx";
        service.CrmAuthenticationTokenValue = token;
        service.Credentials = System.Net.CredentialCache.DefaultCredentials;
    }

    public override void PostExecute()
    {
        base.PostExecute();
    }

    public override void ContactInput_ProcessInputRow(ContactInputBuffer Row)
    {
        contact cont = new contact();

        if (!Row.FirstName_IsNull)
        {
            cont.firstname = Row.FirstName;
        }

        if (!Row.LastName_IsNull)
        {
            cont.lastname = Row.LastName;
        }

        if (!Row.Phone_IsNull)
        {
            cont.telephone1 = Row.Phone;
        }

        if (!Row.Email_IsNull)
        {
            cont.emailaddress1 = Row.Email;
        }

        service.Create(cont);
    }

 

Execute the SSIS package

After coding the SSIS package, right-click on the Contact.dtsx package and then select Execute Package. After the package has executed successfully, you should see the records in CRM.

image

Deploy the SSIS Package

After successfully testing the package, deploying the package is pretty easy. It requires the same steps as the previous version of SSIS. I have included the steps again below.

– Right-click on the CRM 4.0 SSIS project and then select Properties.

– Click on the Deployment Utility tab and set the Create Deployment Utility property to True.

image

– Recompile the CRM 4.0 SSIS project. You should see CRM 4.0 SSIS.SSISDeploymentManifest in the bin\Deployment folder.

– Double-click on the manifest file and follow the wizard to deploy the SSIS package to your SQL server.

Summary

That’s all there is to it! Hopefully you have gotten the idea of how to use the latest version of SSIS to send data to CRM. SSIS 2008 has a lot of improvements to make our jobs easier to integrate systems. In this sample, I only demonstrated how to import records in CRM. In an actual data integration or migration implementation, we still have a lot more to consider such as updating, deleting and error handling. This is one of the many approaches that you can use to integrate/migrate data with CRM. I hope this will help you in your next CRM project.

Cheers,

Darren Liu

Simplify your life with JavistaCRM

CRM for iPhone

Download JavistaCRM on iPhone v1.5

Start your trial experience of JavistaCRM

FAQ concerning JavistaCRM

Question, Feedback or to be a partner

Marketing Lists – Newly Discovered Attributes

January 4, 2010 Leave a comment

There are many attributes that come with the CRM system. Most of them have been published on the forms from the get go when you open up the application. The remaining ones have been created in the schema and await our use in customizing an entity form. While doing some work for a new project I happened across 3 attributes in the Marketing List entity I didn’t realize existed. I immediately put one of them to use – Members Count.

The task I was working on was to quickly see the effect of removing or adding contacts from a particular marketing list as I adjusted the count for a post card mailing we were planning on executing. The typical way this would be done is to make the adjustment to the list and then either:

1. Page through each screen in the Form to then multiply the number of records times the number of full pages of records and then add the remaining partial page count.

2. Export to Excel using the Static Worksheet with “Records from all pages in the current view” option. When Excel opens up with the list of records, scroll down to the last row and subtract by one to get the count. Another version of this approach is to export to Excel by creating a Dynamic Worksheet and then just refresh the worksheet as needed to get the revised count.

Both of these approaches are well known work arounds for determining the total number of records returned by a View.

BUT, dumb luck being what it is I discovered three attributes that I had never explored before and one of them exactly met my immediate need – Members Count (schema name: membercount).

clip_image002

I created a new section on the Marketing List form and began testing the Members Count attribute.

Here is what I have discovered:

1. Members Count is a ‘static’ integer value which is updated only on the On Load event of the form.

2. Adding or Removing list members while the form is open doesn’t change the displayed value (see #1 above).

3. The count only includes Active Members on the list and ignores any members whose record has been deactivated, but is still associated with the list.

clip_image004

I haven’t explored the use of the Ignore Inactive List Members and Exclude Members Who Opt Out attributes yet.

I am now headed in the direction of exploring pre-existing but unpublished attributes for other entities to see what undiscovered gems might be out there.

Jerry Weinstock

Simplify your life with JavistaCRM

CRM for iPhone

Download JavistaCRM on iPhone v1.5

Start your trial experience of JavistaCRM

FAQ concerning JavistaCRM

Question, Feedback or to be a partner

Best practice for refreshing a Microsoft Dynamics CRM test environment

January 4, 2010 Leave a comment

For high availability Microsoft Dynamics CRM deployments, it is recommended that you have additional environments for test, Dev, and QA, so you can manage changes to your configuration without impacting users. This is also a good idea for disaster recovery, so if the production environment fails you can roll over to one of the other environments.

To have a valid test environment, you need to closely approximate your production Microsoft Dynamics CRM environment, with current configuration and data. So what is the process to “refresh” the data and configuration in your test environment to match the production environment?

Refresh a Microsoft Dynamics CRM test environment to match the production environment:

  1. Deactivate the test Microsoft Dynamics CRM organization using Microsoft Dynamics CRM Deployment Manager. On the test Microsoft Dynamics CRM server, open Deployment Manager by going to Start–>All Programs–>Microsoft Dynamics CRM–>Deployment Manager. Open the Organizations folder, select your Microsoft Dynamics CRM test organization, and then click Disable from the right side menu. Note that you must be a deployment admin to perform this step.image
  2. Delete the test Microsoft Dynamics CRM organization in Deployment Manager. After you have disabled the organization, you will be able to delete it.image
  3. Drop the test MSCRM database in SQL Server Management Studio on the test SQL Server environment.
  4. Restore the backup of the production MSCRM database to the test SQL Server environment.
  5. Import the organization to the test environment using Microsoft Dynamics CRM Deployment Manager. In Deployment Manager, click Import Organization, and follow the wizard to point it to the restored MSCRM database.

Thanks to Matt Parks and Ross Lotharius for their input. Ross notes that if you add users to the test environment that you imported, these users may get duplicated in the test configuration database and cause problems with these users logging in to the test environment. The recommendation is to either avoid adding users in the test environment (add them first to production before you import the organization into test) or restore both the MSCRM and configuration databases in step 4. Restoring the configuration database will work, as long as there are no other Microsoft Dynamics CRM organizations in the test environment.

Related Links

Cheers,

Joel Lindstrom

Simplify your life with JavistaCRM

CRM for iPhone

Download JavistaCRM on iPhone v1.5

Start your trial experience of JavistaCRM

FAQ concerning JavistaCRM

Question, Feedback or to be a partner

The Convergence of Microsoft Dynamics CRM and Outlook

January 4, 2010 Leave a comment

I have been running the latest release of Microsoft Dynamics CRM Client for Microsoft Outlook (Rollup 7) for over a month now (I also had the opportunity to be a beta tester for the product team for a month before it was launched) and overall it has been a big improvement in performance and reliability.  You can see the list of improvements on this blog posting http://blogs.msdn.com/crm/archive/2009/10/22/update-rollup-7-for-microsoft-dynamics-crm-4-0.aspx

The key point I want to make on this post is that we are getting there…”the Convergence of CRM and Outlook”.  I think this release is the turning point to get many more of the Microsoft Dynamics CRM users out there (you know who you are, all 1 million+ of you) to install and use the Outlook Client as their primary interface to CRM.  A couple of key turning points for me:

  • Now CRM looks to see if you have a connection to the server.  If you lose your connection, it automatically goes offline, if you get the connection back it automatically goes back online
  • It loads faster on start up and you can read email, look at your calendar etc while it is loading in the background
  • You can shut your close your laptop and reopen it and it still works without logging back into Outlook again
  • The offline client runs very fast…

Starting to work like Outlook!  Is it perfect?  No, but I have been using the Outlook Client since the humble beginnings of Microsoft CRM 1.2 and MSFT has come a long way to delivering on the promise of CRM and Outlook working together.  Just in this last month, I have tracked over 235 emails in CRM (including a nice HTML word mail merge that I sent out to a number of my key contacts about some recent news).  Outlook and CRM have now been woven together in my working style.

I work with many “low tolerance” people that dumped the Outlook Client previously for one reason or another and have seen them come back to it this time and use it.   This continues to be one of the big value propositions of Microsoft in helping to drive user adoption for CRM or any XRM application for that matter.  As complex as these solutions can become, pretty much every user still wants to use Outlook, Word and Excel to do a lot of their every day work.  The intersection of these Office tools and CRM is going to happen.

A couple of hints to make your Outlook Client experience better:

  • Drag the CRM folders that you use most often up to your favorite folders.  I think of it as CRM is now “4 Folders in my Favorite Folders in Outlook”.  I can’t imagine navigating to the bottom of my folder system to go find CRM each time
  • Make sure that email responses to your CRM emails are automatically tracked in CRM (set your settings under the Email Tab of Personal Options to “E-mail messages in response to CRM e-mail”
  • If you do have an issue, run the Diagnostics Wizard (this needs to be in an easier spot for most end users in reality) as it typically solves many of the issues you may be experiencing (Start/All Programs/Microsoft Dynamics CRM 4.0/Diagnostics/Run Diagnostics)

As Aaron Elder always reminds us “You never really arrive”.  I can say that the CRM Product Team has definitely gotten 1 step closer.

Cheers,

Aaron Elder and David Kohar

Simplify your life with JavistaCRM

CRM for iPhone

Download JavistaCRM on iPhone v1.5

Start your trial experience of JavistaCRM

FAQ concerning JavistaCRM

Question, Feedback or to be a partner