/**
* Load an associated view into an IFrame, hide it from LHS navigation menu,
* and remove "Add Existing" button in the associated view.
* @author Daniel Cai, http://danielcai.blogspot.com/
*
* Parameters:
* @param iframe: The IFrame's object, e.g. crmForm.all.IFrame_Employer_Address
* @param navItemId: LHS navigator's HTML element ID of the associated view.
It usually starts with "nav".
* @param relName: The relationship name, this parameter is only required
* when you want to remove "Add Existing" button.
* @param roleOrd: Role ordinary of the relationship, this parameter is only
* required for N:N relationship.
*/function
loadAssociatedViewInIFrame(iframe, navItemId, relName, roleOrd) {var clickActionPattern = /loadArea\(['"]{1}([A-Za-z0-9_]+)['"]{1}\).*/;
url +=
url +=
url +=
url += (!roleOrd) ?
};
var getFrameSrc = function(areaId) {var url = "areas.aspx?oId=" + encodeURI(crmForm.ObjectId);"&oType=" + crmForm.ObjectTypeCode;"&security=" + crmFormSubmit.crmFormSubmitSecurity.value;"&tabSet=" + areaId;"" : "&roleOrd=" + roleOrd;return url;var removeAddExistingButton = function(frameDoc) {if (!frameDoc || !!roleOrd) { return; }var grid = frameDoc.all['crmGrid'];// Locate the "Add Existing" button using its magic id.
btn.parentNode.removeChild(btn);
}
};
removeAddExistingButton(frameDoc);
var btnId = '_MBtoplocAssocOneToMany' + grid.GetParameter('otc') + relName.replace(/_/g, "");var btn = frameDoc.getElementById(btnId);if (btn) {var onReadyStateChange = function() {if (iframe.readyState === 'complete') {var frameDoc = iframe.contentWindow.document;// Remove the padding space around the iframeframeDoc.body.scroll =
frameDoc.body.childNodes[0].rows[0].cells[0].style.padding =
}
};
(
}
navItem.style.display =
iframe.src = getFrameSrc(areaId);
iframe.allowTransparency = "no";"0px";function init() {if (!crmForm.ObjectId) { return; }var navItem = document.getElementById(navItemId);if (!navItem) { return; }var clickAction = navItem.getAttributeNode('onclick').nodeValue;if (!clickAction || !clickActionPattern.test(clickAction)) {return;'none';var areaId = clickAction.replace(clickActionPattern, '$1');true; // Get rid of the white area around the IFrameiframe.attachEvent(
})();
};'onreadystatechange', onReadyStateChange);
Wednesday, February 9, 2011
Monday, February 7, 2011
New Dynamics CRM 2011 Books from Amazon.Com

Working with Microsoft Dynamics CRM 2011 - Paperback (Apr. 15, 2011) by Mike Snyder, Jim Steger, and Kristie Reid
Books: See all 8 items
Email Record Links from a Dynamics CRM Workflow
Link from Richard Knudson's Dynamics CRM Trick Bag
It’s easy enough to email another CRM user a link to a record. If you open up a form for almost any record type in Dynamics CRM, you can pull down the Actions menu and select the Send Shortcut command to do this. Dynamics CRM will open up your mail client, and insert a rather complicated looking link which the recipient will be able to click to navigate directly to the record (assuming they have read permissions!)
For example, here’s what it looks like from an opportunity record:

Here’s what it looks like for an account record:

While your specific links will be different than mine (mine are for records contained in my CRM Online database, and the nasty-looking 25-character GUID uniquely identifies CRM records so it better be different!), the general structure will always be the same. I’ll come back to that point a little later, since it will solve a problem for us.
Suppose I want a workflow to automatically send an email alert any time something important changes about an opportunity record. Here are a few scenarios to illustrate:
As you know if you’ve read my book on Dynamics CRM workflows, there are many things you can do with Dynamics CRM workflows…but unfortunately, this is not one of them! I’ll illustrate with a simple alert email, sent by a workflow that runs automatically any time specified values of the opportunity entity change.
The following screen shot shows the Set Properties form for the workflow’s Send e-mail action. For demo purposes, the email simply goes to me, and I’ve used Dynamic Values to populate the body of the email with presumably interesting information about the current opportunity.
There is an eponymously titled field you can insert for any entity in Dynamics CRM, in this case, using the “{field name{entity name}}” characteristic of the workflow design environment, it’s the {Opportunity{Opportunity}} you can see in the figure. The problem with that is that it’s only a clickable link to the record if it’s on the Regarding field…and the Regarding field only appears if you happen to be viewing the email activity within Dynamics CRM.

Here’s what an email sent by this workflow looks like in Dynamics CRM (e.g., as a History item associated with the opportunity record):

But if, like most people as you prefer consuming your email in Outlook or a non-CRM email client, you never see that Regarding field. For example, Outlook:

Common Record Types
You can use a custom attribute for any entity you want to include a clickable link for by following these steps:
I wrote a book on Dynamics CRM workflows, by the way, and it contains tons of examples like this one and other useful workflows. You can purchase the book on Lulu.com or on Amazon, and if you do, you can also get a (free) subscription to the online version of the book, where you can download the workflows themselves, customizations, and related content.
Here’s a link you can visit to find out more about my book and purchase it
It’s easy enough to email another CRM user a link to a record. If you open up a form for almost any record type in Dynamics CRM, you can pull down the Actions menu and select the Send Shortcut command to do this. Dynamics CRM will open up your mail client, and insert a rather complicated looking link which the recipient will be able to click to navigate directly to the record (assuming they have read permissions!)
For example, here’s what it looks like from an opportunity record:

Here’s what it looks like for an account record:

While your specific links will be different than mine (mine are for records contained in my CRM Online database, and the nasty-looking 25-character GUID uniquely identifies CRM records so it better be different!), the general structure will always be the same. I’ll come back to that point a little later, since it will solve a problem for us.
Problem: a Workflow-generated email cannot send a record link
So…while you can use the menu command I just mentioned to manually email a link to a record, you cannot email a link to a record from within a workflow. This might sound somewhat obscure, but it actually comes up a lot, and when you run into it, it just seems like something you should be able to do! Fortunately, there’s a relatively easy fix you can implement, with just a pinch of customization and a smidgeon of script. I’ll show you the solution next, but first, let me illustrate the problem in a little more detail.Suppose I want a workflow to automatically send an email alert any time something important changes about an opportunity record. Here are a few scenarios to illustrate:
- If the pipeline stage of an opportunity record changes, send an email alerting the sales manager.
- If the current date is with three days of an open opportunity’s estimated close date, send a reminder email to the opportunity owner.
- If an opportunity is closed as “Lost”, send an email alert to the owner’s manager.
As you know if you’ve read my book on Dynamics CRM workflows, there are many things you can do with Dynamics CRM workflows…but unfortunately, this is not one of them! I’ll illustrate with a simple alert email, sent by a workflow that runs automatically any time specified values of the opportunity entity change.
The following screen shot shows the Set Properties form for the workflow’s Send e-mail action. For demo purposes, the email simply goes to me, and I’ve used Dynamic Values to populate the body of the email with presumably interesting information about the current opportunity.
There is an eponymously titled field you can insert for any entity in Dynamics CRM, in this case, using the “{field name{entity name}}” characteristic of the workflow design environment, it’s the {Opportunity{Opportunity}} you can see in the figure. The problem with that is that it’s only a clickable link to the record if it’s on the Regarding field…and the Regarding field only appears if you happen to be viewing the email activity within Dynamics CRM.

Here’s what an email sent by this workflow looks like in Dynamics CRM (e.g., as a History item associated with the opportunity record):

But if, like most people as you prefer consuming your email in Outlook or a non-CRM email client, you never see that Regarding field. For example, Outlook:

Solution: A Pinch of Customization and a Smidgeon of Script (and URL Addressable Forms)
If you’ve read this far, I’m grateful, and you may have noticed the “Link to record” field that’s appeared in a couple of screen shots. That’s the solution, and it uses a technique called URL Addressable Forms, which simply means that every form in Dynamics CRM can be accessed via a unique URL, consisting of an entity-specific prefix combined with a suffix unique to a specific record. You can use the Send Shortcut command I started out by discussing to see what the prefix is for some common record types:Common Record Types
Record Type | Edit Form Prefix |
Account | https://imginc.crm.dynamics.com/sfa/accts/edit.aspx |
Contact | https://imginc.crm.dynamics.com/sfa/conts/edit.aspx |
Opportunity | https://imginc.crm.dynamics.com/sfa/opps/edit.aspx |
Case | https://imginc.crm.dynamics.com/cs/cases/edit.aspx |
Marketing Campaigns | https://imginc.crm.dynamics.com/ma/camps/edit.aspx |
You can use a custom attribute for any entity you want to include a clickable link for by following these steps:
- Customize the entity in question (e.g., Opportunity) by adding a new attribute. I added a custom attribute to the Opportunity entity, called it “Record Link” (it has a corresponding schema name), and gave it the following properties:
The most important is to make it a Type of “nvarchar”, since that’s the only type that has the clickable link format of “URL”. Make sure it’s long enough. I made mine 200, but you can always come back and increase the maximum length (unlike the type and format values, which can’t be changed once the custom attribute is created.)
- Once the attribute is created, the question is how to put the value into it. This really is just a smidgeon of script code – one line of Jscript you can put in the Opportunity form’s OnSave event:
crmForm.all.img_recordlink.DataValue = ‘https://imginc.crm.dynamics.com/sfa/opps/edit.aspx?id=’+crmForm.ObjectId;
I wrote a book on Dynamics CRM workflows, by the way, and it contains tons of examples like this one and other useful workflows. You can purchase the book on Lulu.com or on Amazon, and if you do, you can also get a (free) subscription to the online version of the book, where you can download the workflows themselves, customizations, and related content.
Here’s a link you can visit to find out more about my book and purchase it
Subscribe to:
Posts (Atom)