Knowledge found and lost while working with Microsoft Dynamics CRM
RSS icon Home icon
  • My Mom bought the Internet

    Posted on November 27th, 2007 mitch Print Print No comments

    So my Mom calls me yesterday and tell me she has bought the Internet.

    "Cool," I replied, "Did it come in a box?"

    After I calmed down a bit, she explained that she didn't actually purchase the entire Internet, just the cellular connection service though Alltel.  They live out in the boonies and the closest thing to Internet connectivity they have access to is dial-up.

    While cellular connected Internet is not as nearly as cool as the thought of purchasing the entire Internet, it does bring civilization just a bit closer to my parent's house.  So in a nutshell, I'll take what I can get.

    Meanderings
    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...
    634 views
  • Disabling all fields on a CRM Form

    Posted on November 21st, 2007 mitch Print Print 1 comment

    One of the feature requests that I receive quite often while creating custom CRM solutions is the have the ability to disable all or most of the fields on a CRM form based on data selected by the user.

    I've researched this off and on for quite a while but was never really able to get a solution that I was comfortable with.  Yesterday I started working on the solution in earnest and here is my solution:

     

       1: // disable all of the fields on the form.
       2: DisableFormFields = function(onOff)
       3: {
       4:     var iLen = crmForm.all.length;
       5:  
       6:     for (i = 0; i < iLen; i++)
       7:     {
       8:         o = crmForm.all[i];
       9:         switch (o.tagName)
      10:         {
      11:             case "INPUT":
      12:             case "SELECT":
      13:             case "TEXTAREA":
      14:             case "IMG":
      15:             case "IFRAME":
      16:                 if (o.id != "leadqualitycode")
      17:                 {
      18:                     o.disabled = onOff;
      19:                 }
      20:                 break
      21:             default:
      22:                 break;
      23:         }
      24:     }
      25: }

    This code needs to be placed in the form's OnLoad event.  In this example, we're working with the Lead Entity.

    The DisableFormFields() function is actually attached to the OnChange event for the Lead Status Attribute. I check the value of Lead Status and call DisableFormFields(true) to disable the fields or DisableFormFields(false) to re-enable the fields.

    Since disabling the entire form really wouldn't be a good idea, we need to allow the user to change their mind. As we loop through each of the form fields, we check the id of the field and as long as we don't encounter Lead Status, we set the fields disabled status to either true to disable the fields or false to re-enable them.

    Customization, Dynamics CRM
    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...
    3,168 views
  • On my bookshelf this morning…

    Posted on November 15th, 2007 mitch Print Print No comments

    I noticed this:

    tpascal

    Circa 1987.

    Ah, those were the days….

    Development, Misc
    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...
    874 views
  • Using Metadata to make intelligent programming decisions

    Posted on November 11th, 2007 mitch Print Print No comments

    This morning I released a small utility to update additional birthday information for CRM Contacts.

    During the process of creating this utility, I came upon an interesting design decision.

    The original solution proposed by Microsoft was to create an Integer Attribute to track the birthday month for a Contact.  I felt that it was a little more friendly to use a String Attribute to track the name of the birthday month, instead.

    But, since I wasn't sure which option the user would select, I wanted to make my CRMUpdateBirthdayList utility accommodate both possibilities.  To make this a reality, I turned to the CRM Metadata service to retrieve information about the Contact Entity using the following code:

       1: private EntityMetadata _selectedEntity = 
       2:          _metaDataService.RetrieveEntityMetadata(
       3:          EntityName.contact.ToString(),
       4:          EntityFlags.IncludeAttributes);
    This code retrieves all of the attribute information for the Contact Entity. 
    I then used the following loop to locate the Birthday Month Attribute
    then stored it's data type:
       1: for (int i=0; i<_selectedEntity.Attributes.Length; i++)
       2: {
       3:     if (_selectedEntity.Attributes[i].Name.ToString() == BirthdayMonthAttribute)
       4:     {
       5:         birthdayMonthType = _selectedEntity.Attributes[i].Type.ToString().ToLower();
       6:     }
       7: }

    Once I had obtained the data type, I used the following code to create the appropriate properties that would allow me to update the Contact record:

       1: switch (birthdayMonthType)
       2: {
       3:     case "integer":
       4:         CrmNumber n = new CrmNumber();
       5:         n.Value = d.Month;
       6:         CrmNumberProperty birthDateMonth2 = new CrmNumberProperty();
       7:         birthDateMonth2.Value = n;
       8:         birthDateMonth2.Name = BirthdayMonthAttribute;
       9:  
      10:         // Add properties to ArrayList.
      11:         arrProps.Add(birthDateMonth2);
      12:         break;
      13:     case "string":
      14:         StringProperty birthDateMonth = new StringProperty();
      15:         birthDateMonth.Value =
      16:            CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(d.Month);
      17:         birthDateMonth.Name = BirthdayMonthAttribute;
      18:  
      19:         // Add properties to ArrayList.
      20:         arrProps.Add(birthDateMonth);    
      21:         break;
      22:     default:
      23:         break;
      24: }

    In a nutshell, the above code segment will check the data type for the Birthday Month attribute and if it is an Integer, it create a property with the number of the birthday month.  Otherwise, if it is a String, it will create a property containing the name of the birthday month.

    While it would have been quicker to just have the user provide the data type inside the .config file, I think it makes much more sense to make your application make intelligent decisions based on the available data.  Not only does this cut down on potential errors introduced by the user, but it also reduces the maintenance of your application since it has taken into account the possibility that at some point in the future the administrator may change the way they record the birthday month.

    Customization, Dynamics CRM
    1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
    Loading ... Loading ...
    1,201 views
  • Birthdays in CRM: Revisited

    Posted on November 11th, 2007 mitch Print Print 4 comments

    Last year Phil Richardson and Ben Vollmer both posted solutions that would enable us to better track birthdays within CRM.  In May of 2007, the solution was added to the CRM How To series.

    To review the situation we find that while Microsoft provided us with a Birthday Attribute on the Contact Entity it's really hard to perform a search for birthdays because we need to know at what point the future will a contact's birthday occur again.

    Their solution is to create two custom fields that hold the birthday month and the birthday day.  The addition of these new Attributes allows us to perform Advanced Find operations such as: "Show me all birthdays in December", so we can get birthday cards into the mail.

    The How To article provides instructions on how to add the Attributes in question and provides the JavaScript code to populate those attributes whenever someone changes a Contact's birthdate.

    I would like to suggest a small change to that solution:  Instead of tracking the birthday month by number, I wanted to use the month's name.  You basically follow the instructions in the How To article but when you start to create the Birthday Month Attribute, make it a nvarchar(10) instead of an integer.

    Use the following JavaScript code in the Birthdate Attribute's OnChange event to populate the name of the month in the Birthday Month Attribute:

       1: if (crmForm.all.birthdate.DataValue != null)
       2: {
       3:  var monthList = new Array(
       4:  "January","February", "March",
       5:  "April", "May", "June",
       6:  "July", "August", "September",
       7:  "October", "November", "December");
       8:  
       9:  var bd = crmForm.all.birthdate.DataValue;
      10:  crmForm.all.new_birthdaymonth.DataValue = monthList[bd.getMonth()];
      11:  crmForm.all.new_birthdaymonth.ForceSubmit = true;
      12:  crmForm.all.new_birthdayday.DataValue = bd.getDate();
      13:  crmForm.all.new_birthdayday.ForceSubmit = true;
      14: }
      15: else
      16: {
      17:  crmForm.all.new_birthdaymonth.DataValue = null;
      18:  crmForm.all.new_birthdaymonth.ForceSubmit = true;
      19:  crmForm.all.new_birthdayday.DataValue = null;
      20:  crmForm.all.new_birthdayday.ForceSubmit = true;
      21: }

     

    So that takes care of all new birthdays added to the system.  But what about the birthdays that already exist?

    Well, that took a bit more work since we need to perform an update to the database for each Contact record containing a birthday.

    Attached to this article you will find a small utility that will update the new birthday month and birthday day Attributes you added based on the Contact's birthdate. This utility can be run at any time to update any CRM Contact that contains a Birthdate.

    Download: CRMUpdateBirthdayList

    Review the enclosed CRMUpdateBirthdayList-Readme.doc file for configuration and usage instructions.

    This utility can be run from either the CRM Server or from a workstation on which the CRM Outlook client has been installed.

    Misc
    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...
    1,187 views
  • Solution to "Unable to edit view columns"

    Posted on November 10th, 2007 mitch Print Print 2 comments

    Through the course of the past two years, since I've been working with CRM 3.0, I've run into a very strange situation where I am unable to edit the columns within the CRM View customization editor.

    Basically, you can't select a column and if you can't select a column, you can't move it or change its width.  The only alternative is to export the customizations and edit the columns by hand – something I really don't like to do.

    I ran into this situation again this week ( only the third time in two years, so this is really a rare event ) so I asked my fellow MVPs if they had ever seen this before, and if so, did they have a solution.

    Nithya Balasubramanian replied back with what has got to be the strangest CRM solution that I'd ever heard of: Add about:blank to the Trusted Sites security group within Internet Explorer.

    I decided to use Local Intranet instead of Trusted Sites and after making the change, I was successfully able to edit the Active Contacts view as I normally would.

    Just to verify the results, I logged into another customer's site where I saw the problem, verified the problem existed, added about:blank to Local Intranet and watched the problem disappear.

    Amazing.

    Thanks Nithya!

    Customization, Dynamics CRM
    1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5.00 out of 5)
    Loading ... Loading ...
    1,374 views
  • Calling a custom JavaScript function from a custom toolbar button

    Posted on November 9th, 2007 mitch Print Print 3 comments

    Speaking of toolbar buttons.  Another common practice is to add a toolbar button that will perform some complex operation in JavaScript.  Since you generally don't want the JavaScript itself inside your isv.config.xml file, you need a place to put it where it's easily maintained.  How about in the Form's OnLoad event?

    Buttons are added to the toolbar by modifying the isv.config.xml and inserting code similar to the following:

    <Button
        Title="DoIt"
        ToolTip="Do something interesting"
        Icon="/_imgs/ico_16_1071.gif"
        JavaScript="MyCustomFunction();"
    />

    Inside the Form's OnLoad event, we declare our MyCustomFunction() like this:

       1: MyCustomFunction = function()
       2: {
       3:  alert("we're doing something interesting here...");
       4: }

     

    By adding the function to the OnLoad event, you centralize your JavaScript functions which will usually decrease your maintenance requirements since all of the code is in one place. Also, since we're working inside the form, we have access to the Form's attributes as we normally would.

    Customization, Dynamics CRM
    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...
    1,911 views
  • Adding a toolbar button to create new, related entities

    Posted on November 9th, 2007 mitch Print Print 10 comments

    [unsupported]

    One of my current projects has requirements to add toolbar buttons to allow the user to create a new, related Entity such as a phone call or appointment with a click of a button.

    Buttons are added to the toolbar by modifying the isv.config.xml and inserting code similar to the following:

    <Button
        Title="Phone Call"
        ToolTip="Create a phone call"
        Icon="/_imgs/ico_16_1071.gif"
        JavaScript="locAddRelatedTo(4210);"
    />

    I would like to point out the JavaScript function locAddRelatedTo().  This will open a new window containing a new CRM Entity.  The Entity being created is determined by the parameter passed to the function.  The parameter is the ID of the Entity in question.  In the above example, 4210 is the Entity ID for the Phone Call Activity.  Substitute any valid Entity ID to create a new built-in or custom Entity.

    Customization, Dynamics CRM, Unsupported
    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...
    3,459 views
  • Processing CRM Queue Email

    Posted on November 6th, 2007 mitch Print Print No comments

    One of the steps that people sometimes forget when creating an email enabled queue it to apply to CRM Forwarding Rule to the Queue mailbox.  If you do this, and your queue is in use, you will find unprocessed email in the Queue's mailbox.

    The CRM Forwarding Rule rule only works on new, inbound, email and will not process existing mail items.

    To process the email in the Queue's mailbox, perform these steps:

    1) Create an Outlook profile that allows you to log into Exchange as the CRM Queue user.

    Note: if you have disabled the Queue account within Active Directory, you'll probably need to temporarily enable it for this process to work.

    2) Start Outlook.

    3) Select Tools, Rules and Alerts to open the Rules and Alerts dialog.

    4) Click the Rule Rules Now button.

    5) Select the CRM Forwarding Rule.

    6) Select the Inbox folder on which to run the rule.

    7) Click the Run Now button.

     

    That's pretty much it.

    Dynamics CRM, Installation
    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...
    1,811 views
  • The parameter is incorrect saving a Related Contact

    Posted on November 5th, 2007 mitch Print Print 2 comments

    One of my customers modified the mapping between Account and Contact and from that point forward, the received the following error message ( DevErrors are turned on ) when attempting to add a new Contact to an existing Account:

    crmerror1

    Now that was rather confusing because it only happened if you had an Account open, selected Contacts, then clicked the New button.  Clicking the New button from a Contacts View did not generate an error.

    Solution

    After Googling around a while I ran into this post in the CRM  newsgroups.  Basically, you needed to delete the following mappings:

    Source Schema name: "Address1_addressid"
    Target Schema name: "Address1_addressid"

    Source Schema name: "Address2_addressid"
    Target Schema name: "Address2_addressid"

     

    Thanks to Aami for discovering and posting the solution.

    Customization, Dynamics CRM
    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...
    975 views