Knowledge found and lost while working with Microsoft Dynamics CRM
RSS icon Home icon
  • Using .NET to Develop for the iPhone

    Posted on September 14th, 2009 mitch Print Print No comments

    Today, Novell officially released MonoTouch, a development environment that allows you to write C# .NET code that can be deployed on the iPhone and iTouch.

    I find the whole concept fascinating. So much so that I actually bought a Mac Mini so I could write iPhone apps. ( Due to the iPhone SDK, a Mac is required as a development platform. )

    It will be a change of pace from writing CRM-integrated apps all day. :)

    Development, iPhone
    1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5.00 out of 5)
    Loading ... Loading ...
    526 views
  • Outlook 2007 and Plain Text Email Line Wrapping

    Posted on September 2nd, 2009 mitch Print Print No comments

    This is a bit off-topic for me, but since I ran into it, I blog about it.

    So I’m testing one of my CRM add-ons which involves sending an email to an email-enabled CRM queue.

    I’m sending an email with an XML packet in the email body.  Unfortunately, Outlook keeps hard-wrapping the text by inserting carriage-returns which end up breaking the XML into fragments.

    Fortunately, Slipstick Systems came to my rescue, as always ( anything Outlook/Exchange-related ).

    Anyway, I found a reference to a KB article that mentions how to make Outlook “not wrap” plain text emails going out over the Internet.

    Perfect!

    Other than having to change the Registry Key mentioned in the KB article to:

    HKEY_CURRENT_USER\Software\Microsoft\Office\12.0

    instead of Office\11.0 ( for Outlook 2003 ), everything worked and I can get back to testing.

    Development, Email
    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...
    742 views
  • CRM 4.0 Development Skeleton

    Posted on August 15th, 2009 mitch Print Print 2 comments

    When creating solutions that utilize the CRM 4.0 SDK I often find myself needing to quickly create and test a piece of code that allows me perform a specific function. 

    I’ve created a simple application skeleton to aid in my development efforts. It has the code required to connect to CRM and display the results of whatever code I’m writing.  It is a simple Visual Studio 2008 Windows Forms solution that contains a list box, a large text box and a couple of buttons.  I use the list box and text box to display the results of whatever test I’m working on.

    I find this skeleton especially useful when developing plugins because I need to write and test the code outside of the plugin environment. Once I’m sure that the code is functioning the way I wish, I simply copy and paste it into the plugin.

    You can find this skeleton in the Free Utilities section of this blog.

    Customization, Development, Dynamics CRM
    1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 4.50 out of 5)
    Loading ... Loading ...
    454 views
  • JavaScript Export Tool Updated

    Posted on August 8th, 2009 mitch Print Print 6 comments

    Since I use the tools I write for myself, it’s common for me to find things that need improvement.

    I found myself taking the output from the JavaScript Export Tool and adding it to a Visual Studio solution file so I could more easily examine the JavaScript of a CRM installation.  Since this was a bothersome step, I decided to automate that functionality and add it to the tool itself.

    Version 1.1 will create a Visual Studio 2008 .SLN file containing references to the .JS files created during the export.

    Please let me know if you have any other suggestions.

    Customization, Development, Dynamics CRM
    1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5.00 out of 5)
    Loading ... Loading ...
    607 views
  • Using the New CRM Visual Studio Templates

    Posted on August 3rd, 2009 mitch Print Print 1 comment

    The CRM SDK version 4.0.9 included three Visual Studio templates to help speed up your CRM-related development efforts:

    Available Templates

    • Plug-in
    • Workflow activity
    • CRM Add-on web page

    The templates may be found in the visualstudiotemplates folder when you unzip the SDK package.

    Each template has an accompanying readme.doc file with instructions for installation and usage notes.

     

    Installation

    Installation is fairly straightforward, just perform these steps:

    1) Navigate to the following folder:

    %Documents and Settings%\Visual Studio 2008\Templates\ProjectTemplates\Visual C#

    Note: In most cases, this is your My Documents folder.

    2) Create a folder called CRM.

    3) Copy each of the three template’s .zip file to the CRM folder.

    The templates should now be installed.

     

    Usage

    Using the templates within Visual Studio is fairly simple. 

    For the Plug-in or Workflow Activity, Select File, New Project, navigate to the CRM folder you created, and you should see the following two templates:

    image

    For a web site, select File, New Web Site, then select the AddOnWebPage template shown below:

    image

     

    Plug-In Template

    This template provides the basic skeleton necessary to create new CRM plug-in including an often overlooked requirement to pass in configuration information via the secure and unsecure configuration information parameters ( which can be set with the plug-in registration tool ):

    image

    You’ll need to add references to the Microsoft CRM SDK assemblies and sign your project before you compile, however.

     

    Workflow Activity Template

    This template provides the basic skeleton necessary to create a new workflow activity including attributes and error checking.

    The project has been signed so all you need to do is add references to the Microsoft CRM SDK assemblies, add your business logic, and you’ll be ready to go:

    image

     

    CRM Add-On Web Page Template

    If you’ve ever needed to create a pop-up dialog that looks like the standard CRM 4.0 interface but actually contains your business logic,this will speed your development.

    This template contains a sample dialog with associated styles to replicate the look and feel of the CRM 4.0 dialog.  You just add user interface elements and business logic to make it your own.  Here is how the sample appears:

    image

     

    Conclusion

    Hopefully, these new additions to the SDK should help you jump-start your next CRM-related project.  There are other examples of this type of technology on the web so you may wish to perform a little research to see which solution best fits your needs.

    Customization, Development, Dynamics CRM
    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...
    1,068 views
  • Retrieving State and Status Options via the MetadataService

    Posted on June 9th, 2009 mitch Print Print No comments

    As you probably know, the State and Status options for a CRM entity are linked together.  You can’t change the State options or values but you can change the Status options ( which are generally shown in a picklist ).

    On a recent project, I needed to simulate the Cancel Opportunity dialog through a custom user interface.  Rather than build a hard-coded list of reasons for the cancelation, I decided to use the CRM MetadataService to dynamically pull the data using the following method ( in C# ):

    public SortedList RetrieveStatusList(
                          string entityName,
                          int statusValue)
    {
        SortedList list = new SortedList();
    
        AttributeMetadata attMetaData;
        RetrieveAttributeRequest request =
            new RetrieveAttributeRequest();
        request.EntityLogicalName = entityName;
        request.LogicalName = "statuscode";
        RetrieveAttributeResponse response;
    
        response =
            (RetrieveAttributeResponse)metadataService.Execute(request);
        attMetaData = response.AttributeMetadata;
    
        StatusAttributeMetadata status =
            (StatusAttributeMetadata)attMetaData;
    
        foreach (StatusOption o in status.Options)
        {
            if (o.State.Value == statusValue)
            {
                list.Add(o.Label.UserLocLabel.Label,
                         o.Value.Value.ToString());
            }
        }
    
        return list;
    }

    The method takes two parameters:

    1. The entity name
    2. The state code value

    I am using this method to populate a ASP.NET dropdown list box using the following code:

    DropDownList1.DataSource = RetrieveStatusList("opportunity", 2);
    DropDownList1.DataTextField = "Key";
    DropDownList1.DataValueField = "Value";
    DropDownList1.DataBind();

    In the case of the Opportunity, we have the following State code values:

    Name Value
    Lost 2
    Open 0
    Won 1

     

    Since we are canceling an Opportunity, we use the Lost state, which has a value of 2.

     

    How This Works

    The key to making sense of this process is the StatusOption object.  It contains data for both the Status Reason codes and the State with which are they associated.

    Since we are looking for a specific state, we check the State for the Option and if it matches our expected value, we add it to the list.

    Customization, Development, Dynamics CRM
    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...
    518 views
  • Visual Studio Icon Library

    Posted on February 24th, 2009 mitch Print Print No comments

    I just love accidentally finding valuable information. While looking for something totally different, I found this article by Sara Ford.

    Starting in Visual Studio 2005, you’ll find the Visual Studio Image Library, a zip file that contains over a 1000 images to create applications that have a consistent UI look and feel to Windows, Office, and Visual Studio.

    During the Visual Studio setup, the VS2008ImageLibrary.zip file is installed at \Program Files\Microsoft Visual Studio 9.0\Common7\VS2008ImageLibrary\

    Judging from the comments on the article, I'm not sure many people knew this was there.

    One of the cooler things included in the library are some of those animated icons you see on long operations such as moving, copying, and uploading files.   A few months ago, I probably spent a couple of hours browsing around the web for examples of those.

    Thanks Sara.

    Development
    1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5.00 out of 5)
    Loading ... Loading ...
    950 views
  • Blast from the past: an alternative to a progress bar

    Posted on November 22nd, 2008 mitch Print Print No comments

    I was installing Visual Studio 2008 SP1 today when I noticed that in addition to two different progress bars, they had an alterative progress indicator.  It is purely text based and is fairly simple to implement and consists of the following characters:

     

    \

    |

    /

     

    If you display these characters one after the other, in the order specified above, you will create something we used to call a "spinner," which is has the appearance of a spinning bar.  The spinner will spin at different speeds, depending on how fast you cycle through characters.  This is a great technique for keeping the user informed when you're performing a long operation.  Theoretically, as long as the spinner is spinning, you're application is still working and no hung up in some way.  It's not as flashy as a progress bar, but it can be just as effective.

    I have not seen this technique used in years ( actually a bunch of years ) but it's good see that some of the old ways still work.

    Development
    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...
    710 views
  • Happy weekend everyone

    Posted on September 26th, 2008 mitch Print Print No comments

    It's been a while since I posted anything of relevance so I wanted to say hi to everyone and let you know I'm still alive and kicking and to wish everyone a happy weekend.

    I've been heads-down in about three separate CRM or CRM-related projects and haven't had time to write anything new – but I do have things coming.

    Being so CRM focused sometimes leaves me out of the loop when it comes to other, development-related matters.  Case in point: Just this morning, I was looking at the Visual Studio start page and I see this article:

    How Do I: Create a Basic Language Service Using the Managed Babel System?

    Which, as everyone knows, is about this:

    Create a basic language service by using the Managed Babel System infrastructure provided in the Visual Studio 2008 Software Development Kit (SDK). Incorporate the syntax for your language using the Managed Package Lex Scanner Generator (MPLex) and Managed Package Parser Generator (MPPG) tools and set up and register your language service into the Visual Studio environment. Hilton Giesenow demonstrates how.

    Huh?

    I think I'll crawl back into my CRM cave and worry about managing my Babel at some point in the future…

    Peace out.

    Development, Misc
    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...
    791 views
  • Enhancing CRM 4: Workflows vs. Plugins

    Posted on June 4th, 2008 mitch Print Print 7 comments

    Back in the dark ages, like with CRM 3.0, we were often faced with writing .NET code to provide certain enhanced data manipulation capabilities as either Callouts or Workflow Assemblies.  CRM 4.0 totally changes that mind set – and as a solution developer, you really need to keep that in mind before you jump off into the depths of Visual Studio and the CRM SDK.

    An Example

    To illustrate my point, let's take the PostInvoicePlugin example from the CRM SDK ( v4.0.5 ).

    Note: this example is found in the SDK folder: sdkserverfullsamplepluginpostinvoice

    The purpose of this sample code is to show you how to update a custom field on the Account record whenever a user closes out an Invoice as Paid.  The plugin checks the state of the Invoice, and if Paid, it will update the value of a custom field on Account, using the following code:

    // If the Total Invoiced exists, update it... otherwise set it
    if (parentAccount.Properties.Contains("new_totalinvoiced"))
    {
        ((CrmMoney)parentAccount.Properties["new_totalinvoiced"]).Value += totalAmount;
    }
    else
    {
        parentAccount.Properties.Add(new CrmMoneyProperty("new_totalinvoiced",
                                     new CrmMoney(totalAmount)));
    }
    

    Pretty cool, huh?

     

    An Alternative

    If you haven't spent much time reviewing CRM 4.0 workflows, you should.  You can perform some amazing things without ever writing code.  Let's perform the exact same steps using CRM 4.0 workflow.

    First, we create a workflow based on the Invoice Entity that has the following properties:

    image

    Step 1:

    Create a Check Condition using the following information:

    image

    Step 2:

    Add and Update Record step, on the Related Entity Customer (Account):

    image

    Step 3:

    Click the Set Properties button, then set the Total Invoiced Attribute to the following:

    image 

    Note: Total Invoiced is a custom Money Field.

    By using the Increment by Operator, we are able to increment any existing Total Invoiced amount by the amount found in the Invoice's Total Amount field.

    Final Step:

    Save and Publish this workflow.

    Conclusion:

    So, is there a difference between these techniques?  Not really.  Both accomplish the job in a very similar manner but the Workflow solution requires zero code maintenance and a normal user or administrator can create the workflow.

    The biggest difference between the two techniques is in the timing of the actual update. Plugins can be executed either Synchronously or Asynchronously.   Workflows function in an asynchronous manner.

    The Synchronous operation will modify the data stream as it is being saved to the database, which can introduce a delay in the user's experience, but will provide results back to the user in a quicker fashion.

    Asynchronous operations will happen shortly after the data has been saved which will not impact the user, but which may result in a slight delay between the time the user saved the record and when the value will be updated.

    If you can live with the time delay, I feel that workflow is the way to go, in most cases.  If you can't, then download the SDK and start working through their examples.

    Customization, Development, Dynamics CRM, Workflow
    1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 4.00 out of 5)
    Loading ... Loading ...
    10,312 views