4.14.2005

Sending E-mail from Workflow with Dynamic Data

Microsoft CRM provides an easy to use template editor to create E-mails that can be sent programmatically or manually to contacts, leads and accounts from the CRM web client. Many times, however, it is desirable to send E-mail to other CRM users within an organization to notify the user of new leads, to escalate a service case, or when an account is assigned to the user. The CRM Workflow Manager allows logical or named users to be selected as recipients of E-mails, but there is no documented way of including dynamic data about the related record in the subject or body of the E-mail.

There is an undocumented workaround to handle this, and it adds great flexibility to CRM workflow-generated E-mails. Depending on the entity that the E-mail is generated for, different fields will be available to your workflow. For example, if you are creating an E-mail with information about a lead, you might want to include the lead’s name and phone number in the E-mail. Here’s what you would type to add these fields:


&lead.fullname;

& lead.telephone1;


It is important to note that the & must precede the data slug and the ; must immediately follow. To locate fields that are available for a certain entity, in the CRM web client, go to Home > Settings > System Customization and double-click the entity you are working with. In the customization screen, click on “Customize Form.” Locate the field you want included in your E-mail and double-click it to view its properties. Click the Schema tab and note the field name. This is the name to use in your data slug.

To find additional field names, on the CRM server, open Deployment Manager and click on Schema manager to view a list of entities. Expand the entity and click on its Attributes folder. This will display all the fields for that entity.

In addition to adding dynamic data, you can also add hyperlinks directly to the related records. Entities can be linked to by their GUID, which is located in the entityid field, such as the leadid or accountid. Here are sample tags for linking to the different kinds of objects available to workflow. Make sure to replace crm with the name of your CRM server.

Sales Objects:


<a href="http://crm/SFA/opps/edit.aspx?id=&opportunity.opportunityid;">&opportunity.name;</a>


<a href="http://crm/SFA/leads/edit.aspx?id=&lead.leadid;">&lead.fullname;</a>


<a href="http://crm/SFA/accts/edit.aspx?id=&account.accountid;">&account.name;</a>


<a href="http://crm/SFA/conts/edit.aspx?id=&contact.contactid;">&contact.fullname;</a>


<a href="http://crm/SFA/invoice/edit.aspx?id=&invoice.invoiceid;">&invoice.name;</a>


<a href="http://crm/SFA/salesorder/edit.aspx?id=&salesorder.salesorderid;">&salesorder.name;</a>


<a href="http://crm/SFA/quotes/edit.aspx?id=&quote.quoteid;">&quote.name;</a>


Customer Service Objects:


<a href="http://crm/CS/cases/edit.aspx?id=&incident.incidentid;">Case &incident.ticketnumber;</a>


<a href="http://crm/CS/contracts/edit.aspx?id=&contract.contractid;">&contract.title;</a>

19 comments:

Anonymous said...

Hey:

What method is available to show the Value of Picklists and Boolean fields using slugs? When I use a slug for a custom/System picklist, I get the integer value.

e.g., &account.customertypecode;

Will return a #. Is it plausible to use the jscript method for displaying the string value:

e.g., &account.customertypecode.returnValue

??

--Dodd

Anonymous said...

This is a reply to Dodd.
The actual picklist display value is stored in the StringMap table (as are all picklist values) in the CRM DB.
You can have the workflow call an external web page - whether it's ASP or ASPX would be up to your own skillset/preference - but if you pass in the GUID of the Lead/Case/whatever - you can use SQL calls to retrieve the entity properties that you want as well as any other data from any DB you need - and use CDONTS or some other mail sending program to get out the message formatted as you would like.

Anonymous said...

I am not able to get this to work.
I have created a manual workflow on the Contacts Object. Here is what I have in my Email Action.
Dear &ContactBase.firstname;

This is a test to see if we can add CRM data fields and also an Attachment.
This is the FullName: &Contact.fullname;
This is the Phone number: &contact.telephone1;

It is not pulling data into my email it is only pulling in this exact verbiage. I have tried to restart my workflow service and it still doesn't work.
Any ideas?

Matt Wittemann said...

Instead of &ContactBase.firstname; you need to use &contact.firstname;

As for the other data slugs, they should work. This has been tested and used extensively on CRM 1.2 systems. Make sure you have data in the fields and that you aren't having other problems sending email templates from CRM.

Anonymous said...

Hi,
I have a problem with these slugs. I created a workflow which assigns incidents to different queues based on the value of a custom picklist. I inserted e-mail notifications and tasks to the workflow and now I can see a strange thing: slugs are working properly in tasks, but not in e-mails (I'm not using e-mail templates because of the addressee limitations). I already double-checked the syntax, it is OK, but slugs are inserted into the email messages as text instead their value.

Have you ever seen this? Any idea what I made wrong?

Anonymous said...

Hi,

Why would the templates that come with CRM be marked as (Internal) when they in fact go to the addressee on the opprtunity or lead? This seems like such a major oversight on MS part. Esecially when they use examples of notifcation of opportunities internally.

A.

Anonymous said...

@account.name; works well.
&account.owneridname; does not
What would I use to retrieve the current owner of the account shown above?

Anonymous said...

Excuse the previous post

&account.name; works well.
&account.owneridname; does not.

What would I use to retrieve the current owner of the account shown above?

Anonymous said...

I am attempting to create an Email activity when a task is not completed.
Within that Email I am trying to use data slugs to display the company
infomration. This activity is created when an Order is fisrt created and is
an Order workflow. I have the following code in the body of the Email:

Customer: &contact.fullname;<BR>

Order Name: &salesorder.name;<BR>

Order Date: &salesorder.createdon;<BR>

Order Description: &salesorder.description;<BR>

Whne the Email is received by internal users it has the exact verbage above
and does not display the actual pulled data? Any ideas what I am doing wrong?
Any help would be appreciated.

Anonymous said...

Could I use "Slugs" to create a workflow rule that would create a support case when e-mails arrive in the "support" queue that I have created on my CRM server?

Thanks!

Anonymous said...

HI

I have a slightly funny request. My client are using the service module of CRM. The case owner then has certain time periods within to resolve the issue. This is managed by the wait functionality within workflow. My question is: Can you somehow change the sender address as the client wish the mail to be from the support queue and not the owner. I can't see a way round this though.

let me know at brunicholson@hotmail.com

Dave O'Hara said...

We've been using CRM for a while now and are just discovering what workflows can do for us. Unfortunately, I'm having some real issues with the dynamic data in emails. I've followed the advice above but still are just getting the "&lead.fullname;" text in the email. Suggestions on what to look for??

Sarah B. Galaxy said...

I tried to make this work within a Workflow Manual rule, wherein the Contact.Salutation = &Contact.firstname;

It didn't work. I've tried it with different cases, variety of syntax, but it's not working. Any ideas would be much appreciated!

Anonymous said...

Does this work with CRM 3.0? I end up with a new record, instead of opening up a page to the existing record.

Matt Wittemann said...

No, this undocumented "feature" has been discontinued in 3.0, but you can insert dynamic data using the built-in tools. So far though there is no easy way to create a hyperlink to a specific record in a template or workflow email. If you search the MS newsgroup, some folks have come up with ways to build .net assemblies that will make this possible.

Anonymous said...

Is there a way to change the recipient of the emails? I know you can select Account, Contact, Owner, etc. but is there a way to select a custom field that we enter email addresses into? We want to send and email to a person once their case is resolved, however we relate the cases to an Account, not a contact record. An email adddress in entered on the case record in a custom field. This in CRM 1.2, but will be upgrading shortly, so either will help.
Thanks.

Matt Wittemann said...

This has been frequently requested, but there isn't any way to send emails through workflow to addressees that are not in the customerid field. I'm sure there a way to do this with some custom development, but not out of the box.

Anonymous said...

Hello,

In CRM 4.0, placed the following href in workflow email body, but no luck for hyperlink. Kindly suggest.

&opportunity.name;

-Mac

Matt Wittemann said...

The method referenced in this blog post was designed for CRM 1.2. For CRM 4.0, unfortunately you will have develop a custom workflow activity that gets the GUID of the object in question and constructs a URL with it that points to the record. Once deployed, your custom workflow activity would be available in the workflow rules interface where you or your users could use it in configuring your workflow to send an email with the link. I'd start with the SDK to look into how to build this.

 
ICU MSCRM © 2004-2009