From Sonoma Partners Blog
A long, long time ago (think 2008), I wrote a blog post and provide some simple code to provide the record id and subsequent url’s for workflow alert emails. As we moved into CRM 2011, I have some good news and some bad news.
- The upgrade of this utility worked like a charm for our production system.
- This workflow assembly is still needed, as CRM 2011 still doesn’t provide the record id in workflow or the url.
- Workflow assemblies aren’t yet permitted on CRM Online, so this technique only applies to CRM on-premise deployments.
Even though the original assembly upgraded fine, I went ahead and rewrote the assembly to leverage the new WF 4.0 and activity pattern that the CRM 2011 SDK is promoting. What is even cooler, is that now with CRM 2011 Solutions, installation (and removal) of this utility is a snap!
Download the managed solution, and import it into your Dynamics CRM 2011 On-premise edition. Once installed, you can access the utilities by clicking Add Step in the workflow editor.
Select Url Builder and update the input parameter with the url for your CRM system. Replace server and org with your correct values, and also replace entity with the appropriate entity (such as lead, account, sonoma_project, etc)
That’s it! Now you can use the output values from this assembly in your workflow rules. The Url Builder returns 3 values:
- Entity Id – The GUID of the record that instantiated the workflow process
- Formatted Url – The url from the input property with the entity id formatted in HTML. Very useful for alert emails, as it will automatically be hyperlinked.
- Output Url – This is the url without the HTML formatting. This can be useful if you are using it to populate a field or integrating into another application that may do it’s own formatting.
I have also included a simple method (Format Line Breaks) for taking text with new lines (\n) and formatting it with HTML < br > statements which provides better readability for emails that include text area attributes in their message.