Jeremy Winchell

June 2007 - Posts

Embedding Direct Links To CRM In A Workflow Email

I can't think of a single CRM implementation that I've been involved in where workflow was not used to send any emails.  Every implementation has used the workflow engine to send emails when records are created, ownership changes, or when Opportunities are closed as a win/loss.  The workflow engine is robust enough where we can embed a lot of detail into the body of the email about the record itself, but what if the user wants to actually view that record in CRM?  Even in the Outlook client this can be a 3 step process:

  1. Open up the Email
  2. Click View In CRM, this opens up the actual email activity in CRM, not the record we want to view
  3. Click the Regarding Object Link

Now you are finally at the actual record you want to view.  If you have Office 2007 there is now a button on the ribbon called View Regarding which cut's out a few steps from above.  If you're not fortunate enough to be using Office 2007 yet, wouldn't it be nice if you could just embed a link in the body of the email message that provides a direct link to the record in CRM?  Fortunately, it's relatively easy to do with a custom attribute and a little bit of Javascript. 

Step 1 - Create A Custom Attribute To Hold The URL
For this example we'll just call our attribute:  new_urllink with datatype varchar

Step 2 - Add The Appropriate Javascript to the OnSave() Event
The Javascript required varies depending on whether the entity is a custom entity or a standard out of the box entity.  The Javascript is labeled appropriately below.  The Javascript checks to see if this is an update form and that the new_urllink attribute is empty.  If it is, then it will build the Url link.

Use the code below for a standard CRM entity (Example Below is for the Account Entity):
var objId;
var accountUrl;
if((crmForm.all.new_urllink.DataValue == null) || (crmForm.all.new_urllink.DataValue == ""))
{
   if(crmForm.FormType == 2)  //Checks to see if this is an update Form  (value of 2)
   {
        var embedUrl;
        accountUrl = "http://crmdemo/sfa/accts/edit.aspx";   //Default Path to the Edit.aspx page for an Account
        objId = crmForm.ObjectId;  //Retrieves the ID of the current object
        embedUrl = accountUrl + "?id=" + objId;  //pieces together the items required for a full Url
        crmForm.all.new_urllink.DataValue = embedUrl;  //Sets the value of the field
        crmForm.all.new_urllink.ForceSubmit = true;
        crmForm.Save();
    }
}

Use the code below for a custom CRM Entity:
var objId;
var objType;
var customUrl;
if((crmForm.all.new_urllink.DataValue == null) || (crmForm.all.new_urllink.DataValue == ""))
{
     if(crmForm.FormType == 2)
     {
          var embedUrl;
          customUrl = "http://crmdemo/userdefined/edit.aspx";
          objId = crmForm.ObjectId;    //Gets the ID of the current record
          objType = crmForm.ObjectTypeCode;  //Gets the type code of the custom entity
          embedUrl = customUrl + "?id=" + objId + "&etc=" + objType;  //pieces together the Url
          crmForm.all.new_urllink.DataValue = embedUrl;
     }
}

Step 3 - Create The Associated Workflow
Now you can create a notification workflow and all you need to do is add this new_urllink field to the body of the email. 

Step 4 - Your Done!

A List of Common Url's For CRM Entities:
You can find the paths for CRM Entities rather easily by browsing to the home directory of the CRM Website, if it's installed on the default website the path would be <drive>\inetpub\wwwroot.  Once you have access to the CRM Website files find the folders that contain the edit pages for the various entities:

  •  SFA - Sales Force Automation (accounts,contacts etc)
  •  CS - Customer Service (cases,contracts etc)
  •  MA - Marketing Automation (campaigns, marketing lists etc)


Sales Force Automation:
Accounts:  http://<crm-url>/sfa/accts/edit.aspx
Contacts:  http://<crm-url>/sfa/conts/edit.aspx
Leads:  http://<crm-url>/sfa/leads/edit.aspx
Opportunities:  http://<crm-url>/sfa/opps/edit.aspx

Marketing Automation
Campaigns:  http://<crm-url>/ma/camps/edit.aspx
Marketing Lists:  http://<crm-url>/ma/lists/edit.aspx
Campaign Response:  http://<crm-url>/ma/campaignresponse/edit.aspx

Case Management:
Cases:  http://<crm-url>/cs/cases/edit.aspx
Contracts:  http://<crm-url>/cs/contracts/edit.aspx
KB Articles:  http://<crm-url>cs/articles/edit.aspx

Custom Entities:
Custom:  http://<crm-url>/userdefined/edit.aspx

*Please substitute the actual url of the CRM Implementation you are working with where you see <crm-url> in the links above.


 

Hiding Unwanted Navigation In CRM

Have you ever wanted to hide certain Navigational items that exist CRM forms?  One request we get from time to time is whether or not it is possible to hide the Sub-Contacts menu item, see the image below, from the Contact Form.  In fact, this is relatively easy to do.  All you need is a basic understanding of HTML and JavaScript.

To Get Started, Follow the Instructions Below

Find the ID of the Sub-Contacts Section:

  1. Open A Contact in Microsoft CRM 
  2. With the Contact Open, Press Ctrl + N to open the Contact in a new window
  3. In Internet Explorer Click View -> Source
  4. When the HTML opens in Notepad do a search for  Sub-Contacts, results are in the image below
  5. Just before the highlighted text you will see:  id="navSubConts", write down stuff between the "" signs.Contact Form HTML

Add the Javascript Below to the OnLoad Event of the Contact Form:

  1. Open CRM in the Web Client
  2. Click Settings -> Customization -> Customize Entities
  3. Double-Click the Contact Entity
  4. Click Forms & Views in the left-hand pane
  5. When the list of Forms & Views appear in the right-side, double-click Form
  6. In the right-hand pane, Click Form Properties
  7. Click OnLoad and Click Edit
  8. Paste the following Javascript in the box:
    1. document.getElementById("navSubConts").style.display = "none";
  9. Check the Enable Event checkbox


  10. Click Save & Close twice and then click Publish

Test The Script:

1. Open up a Contact in CRM, if you're script is working correctly the Sub-Contacts menu option should now be gone, just like the image below:

Hidden Sub-Contacts Record

You can use this same technique to hide other menu items in not only the Contact form within CRM but in any of the other CRM Forms as well.  Now you have more control over what the users can and can't do in CRM.  The main key to getting this to work is finding the right ID value in the HTML code.  I've noticed that most, if not all of the Navigation is stored with <div></div> tags.  If you can find the correct ID, then the rest is pretty easy.

What If: You can't remove columns from a View

I ran into an issue where I could add columns to a View but I could not remove columns.  When I put the mouse over the column it switched to a hand indicating that I could click the item.  However, when I did click on the column.... nothing happened.  Usually the column header turns green letting me know that it is indeed selected.  After scouring the web and the CRM forums I found the solution,  about:blank.

 In the Trusted Sites zone in Internet Explorer you need add about:blank as a Trusted Site.  If you're not familiar with how to do this, you can follow the instructions below:

  1. In Internet Explorer Click Tools -> Internet Options
  2. Click the Security Tab
  3. Click Trusted Sites
  4. Click Sites
  5. Type about:blank
  6. Uncheck Requires Server Verification (if checked)
  7. Click Add, then Ok

Now if you re-open CRM you will be able to remove Columns from a View.

Inetium Is A Finalist For Microsoft CRM Partner of the Year

On Monday, Microsoft announced Inetium as a finalist for the MBS Microsoft Dynamics CRM Partner of the Year.  Over 1,800 companies submitted applications  and we were one of three finalists up for this award.  The winner will be announced at the Microsoft Worldwide Partner Conference in Denver July 10-12, 2007.  We are excited to be recognized and this is a great honor for Inetium and our CRM Practice.

To read Microsoft's announcement click here

Copy CRM Contents To The Clipboard

I had a client ask whether or not I could add a button to the Account Form in CRM that would copy and format the address so that they could paste it into an Email or a Word document.  There is a function that you can call from Javascript/VBScript that will allow you to copy text, URLs etc to the clipboard for use in other applications:  window.clipboardData.setData(tag,value);

Step 1: Determine which fields on the Form we need to capture and the schema name

  • In this case we wanted to capture the following:
    • Account Name (name)
    • Street 1  (address1_line1)
    • Street 2  (address1_line2)
    • City (address1_city)
    • State (address1_stateorprovince)
    • Zip Code (address1_postalcode)

Step 2: Write the necessary Javascript in Notepad (case sensitive)

var texttocopy;
try
{
texttocopy = crmForm.all.name.DataValue + '\n';
texttocopy += crmForm.all.address1_line1.DataValue + '\n';
texttocopy += crmForm.all.address1_line2.DataValue + '\n';
texttocopy += crmForm.all.address1_city.DataValue + ', ' + crmForm.all.address1_stateorprovince.DataValue + '  '  + crmForm.all.address1_postalcode.DataValue + '\n';

window.clipboardData.setData('Text',texttocopy);
}
catch(e)
{}

Step 3: Edit the isv.config.xml file to add the Copy Address button

  1. Browse to the isv.config.xml file (<crm_website_folder\_Resources\isv.config.xml)
  2. Make a backup copy of isv.config.xml file
  3. Open isv.config.xml with Notepad
  4. Add the following line between the <Entities></Entities> XML Tags
    1. <Entity name="account">
    2. <ToolBar ValidForCreate="1" ValidForUpdate="1">
    3. <Button Title="Copy Address" ToolTip="Copies the Account Address To The Clipboard" Icon="/_imgs/ico_18_4004.gif" JavaScript=" " />
    4. </ToolBar>
    5. </Entity>
  5. Copy and Paste your Javascript from Step 2 between the double quotes in Line 3
  6. Save the isv.config.xml file

Step 4:  Test the Button

  1. Open up an Account In CRM
  2. Click the Copy Address  button
  3. Open Wordpad/Work/Outlook or some other application
  4. Click Edit -> Paste or hit Ctrl + V
  5. The formatted address from CRM should appear

This will work on IE 6.0 and IE 7.0.  The window.clipboardData.setData function can also be used to copy URLs.  If you want to copy the URL of the open record use this Javascript instead:

var url;
url = window.location.href;
window.clipboardData.setData('Text',url);

CRM 3.0 List Web Part for Sharepoint 2007 Is Available

Microsoft released a new version of the CRM 3.0 List Web Part.  The List Web Part is now compatible with MOSS (Sharepoint 2007).  The first release of the CRM List Web Part was only compatible with Sharepoint 2003.  You can download the new CRM 3.0 List Web Part using the link below.

http://www.microsoft.com/downloads/details.aspx?FamilyID=bc9b3526-decf-4057-a530-91840c0d5401&DisplayLang=en