Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Kids, don't try this at home!

Tips & Tricks for C#, ASP.NET and CRM

  • Web Form to Dynamics CRM 4

    We've decided to release another component we've been using internally. This little webcontrol allows you put pass data from a Web Form to Dynamics CRM 4.

    How does it work?
    Create a UserControl to layout the form.

  • Dynamics CRM - Writing FetchXml Queries

    While browsing the online Dynamics CRM SDK a while back I noticed that FetchXml had a XSD schema. So I grabbed the xsd.exe tool from Visual Studio, generated a cs file to see if I can use that to create FetchXml queries. Here are my findings.

    To generate the cs file
    xsd.exe /c /n:ExamplNamespace FetchXml.xsd

    You'll notice that the resulting code file has an object array called Items, if have a look at the metadata attributes on that field you'll see which elements are supported. For example the "fetch" class Items array will support "entity" and "order"; how do we use it?

  • Dynamics CRM 4 Visio Stencils

    We have decided to release the Visio Stencils we've been using for Dynamics CRM 4 projects, find out more about them here.

    Sneak peak of the shapes you can use on Create/Update (eg: Popup windows)



    Here is the Account screen duplicated with the stencil set. You'll notice subtle differences, but to the client it looks like the real thing.



    Enjoy

  • CRM 4 Activity Direction Indicator (experimental)

    I've been trying to change the icons under History for each entity to show the direction of the email or phone call.

    Using Fiddler I found out that areas.aspx was responsible for rendering the grid when you click on History, then when you click on the Refresh button or create a new Activity it automatically refreshes the grid, that call is made into the AppGridWebService.asmx which returns the formatted html of the grid.

    Unfortunitely I'm not sure how I can hook into the .asmx and modify the returned html.

    Leaving AppGridWebService.asmx aside for now, areas.aspx was easy to hook into, here is the result.

    1st Phone call: an outbound call which is displaying the custom outbound phonecall image.
    2nd; an inbound call, lastly the email is an outbound email with a custom icon.

    To hook into areas.aspx create a new HttpModule then on BeginRequest

  • CRM 4 Incremental Numbering for any Entity

    UPDATE 08/01/2009
    - Project is now on CodePlex (http://www.codeplex.com/crmnumbering/)

    MYOB can only take 8 characters and accountants don't like seeing cryptic Invoice Numbers that CRM generate, so we ended up writing a custom plugin that automatically incremented each invoice. Keeping extensibility in mind we made it work with any customizable entity. Here is how we did it.



    We created a simple organization owned entity that held the type of entity you wanted to increment, the property/field you wanted to increment and the current/starting position.
    The field to increment must be of type integer.

    Next we wrote a plugin that hooked into the Pre-Create event synchronously, check the target, get the incremental settings for this entity, make sure the property specified is not in the property bag, increment the current number and update our custom entity with the newest number.

  • CRM 4 Custom Workflow to Validate NZ Bank Account/IRD Number

    Recently we created a payroll solution which integrated with Microsoft Dynamics CRM 4, part of that was to validate the Bank Account and IRD Numbers.

    Here's a screenshot of a sample workflow. You can download the code from here.

    Workflow

    Solution contains a Util.cs class which you can use on your other projects to validate New Zealand Bank Account & IRD numbers  as well as 3 workflow activities:

    - BankAccountNumberValidator.cs
      Validates the bank account number and returns true/false (IsValid property)

    - CleanBankAccountNumber.cs
      Given a bank account number it cleans and formats it to xx-xxxx-xxxxxxx-xxxx

    - IRDNumberValidator.cs
      Validates the ird number and returns true/false (IsValid property)

    Enjoy, keep and eye out for more CRM goodies...

  • CRM 4 Custom Workflow Activity Editor Bug/Fix

    Description
    Using the workflow editor, if you open up a custom workflow activity and being to edit a step, if that step contains a dynamic value (slug); it duplicates it. First time you add the dynamic value it works fine, after you save and close then reopen that step you'll see the dynamic value displayed twice.

    eg:
    before save and close: {SomeField(Entity)}
    after save and close: {SomeField(Entity)}{SomeField(Entity)}

    Reproduce
    1. Create a custom workflow activity or compile and register one of the supplied workflows from CrmSdk 4.0*
    2. Restart IIS
    3. Create a new Workflow
    4. Add a new workflow step (The custom activity you created/registered in step 1)
    5. Assign a dynamic value to one of the properties
    6. Save & Close
    7. Reopen the step, you'll see the dynamic value/slug displayed twice

    Fix
    *Unsupported*
    1. Go into the server, SFA\workflow\ folder
    2. Open customactivityform.aspx in notepad
    3. Find line 31 and 34, you'll see that the same call is duplicated twice, comment one of them out

  • CRM 4 Outlook Offline Client & Vista SP1

    While trying to install the CRM 4 Outlook Offline Client on a Vista SP1 machine we got the following error:
    Sql Express - "Installation Failed"

    Nothing in the event log and nothing listed under details. If you get the same error here is how you can get around it.

    - Download SQL 2005 Express SP2
    - Install it, but make sure you uncheck 'Hide advanced option' on the installer -> select 'Named Instance' -> Name: CRM
    Make sure you specify the instance name as CRM, otherwise the installer will complain and say "Installation Failed".

    - Run the Configuration Wizard
    * If the current user is not part of the Administrators group or is not the Administrator it'll say unable to access the database.
    - Download SQL Management Studio
    - Go into Security -> select/add the user -> asign the SysAdmin role (full control to the sql server, I didn't bother trying to find out the minimum permission required to get CRM Outlook installed)

    Another error we noticed
    "An error occured loading Microsoft Dynamics CRM funtionality. Try restarting Microsoft CRM Outlook. Contact your system administrator if errors persist."

    If you try opening the Configuration Wizard it says:
    "Microsoft Dynamics Configuration for Outlook with offline access has already been configured for use on this computer. Only one user can be configured per computer for Microsoft Dynamics CRM for outlook with Offline Access."

    To fix that make sure SQL CRM instance has been started.
    Strange error messages, would have been nice if it said "Could not connect to the sql server."

  • NZify Microsoft Dynamics CRM 4

    While customizing CRM 4 we started noticing we were making the same changes over and over again for different clients. So we standardised CRM 4 for New Zealand. Thanks Mark for the initial idea, now we import and publish this set of customizations on any new installation.

    Here is a list of all the customizations:
    Account
    - Removed 'Other Phone'
    - Moved 'Currency' to the Administration tab
    - Modified the Address section
        - Physical & Postal (2 sub sections)
             - Street, Suburb, City, Postal Code, Country
        - Removed 'Address Type', 'Phone', 'Shipping Method'

    Address
    - Removed 'Phone 2'
    - Moved 'Address Contact' to 'Customer Address Information'
    - Modified the Address
        - Address Name, Street, Suburb, City, Postal Code, Country
    - Modifed the 'Preview' view

    Contact
    - Similar to the Account
    - Modified the Views to include 'Mobile Phone' & 'Email Address'
    - Removed 'Pager'
    - Mapped 'Fax' field from Account to Contact

    Lead
    - Similar to the Contact
    - Modified the 'Industry Code' to a new list from Statistics NZ

    Invoice, Quote & Order
    - Modified the 'Address' tab (re-arranged the fields, 'Street 3' and 'State/Province' is system locked; couldn't remove completely)

    User
    - Similar to the Contact
    - Changed 'Service Calendar Form' to match

    You can download the customizations file from: http://www.dotheyknow.net.nz/customizations_150908.zip