Birthday reminder workflow in CRM

Note: Most of this is for CRM 2011 but it does work in CRM 2013 as well.

Also most of my information I got from these sites below done by Michael Scott he explains in detail how to accomplish this but I changed my JScript a little.

http://blogs.msdn.com/b/crm/archive/2008/01/08/part-1-happy-birthday-via-workflow-using-client-side-scripting.aspx

http://blogs.msdn.com/b/crm/archive/2008/01/11/part-2-happy-birthday-via-workflow-using-custom-workflow-activity.aspx

To Achieve the Automatic Birthday Reminder via CRM, follow the steps below:

Step #1: Create the Attribute

Create a custom datetime attribute called Upcoming Birthday (schema name should be new_upcomingbirthday). The attribute should have Date Only format.

How do I do it?

1. Open the Entity form for the Contact entity (click SettingsCustomization, Customize Entities, and select Contact from the grid).

2. Create a new attribute (from the Attributes grid).

3. Set these properties and Save and Close the form:

Display Name: Upcoming Birthday
Name: new_upcomingbirthday
Type: datetime
Format: Date Only

4. Publish the customizations to the Contact entity (under Actions menu, select Publish)

Step #2: Updating the Attribute

Client-Side Scripting – Update the attribute based on changes to the birthday field.

Pros: Quick, simple, very little coding required, no .NET assembly needs to be registered.
Cons: Attribute needs to be visible on the form, relies on JavaScript

Option #1: Client-Side Scripting (New there are other steps to do this but I went with JScript)

1. Add the new Upcoming Birthday field to the form

2. Add the code (shown below) to the onLoad event.

3. Now how this code works is when you add the contact or user’s birthday to the birthday field the code below will set the upcoming birthday field to the following year, then we can create a workflow to trigger on that day and then set the upcoming birthday by an increment of 12 months.

Code

function onLoad() {
setUpcomingBirthday();
}

function setUpcomingBirthday() {
var birthday = Xrm.Page.getAttribute(“birthdate”).getValue();
var upcomingbirthday = Xrm.Page.getAttribute(“new_upcomingbirthday”).getValue();
if(birthday != null && upcomingbirthday == null) {
var today = new Date();
var yearEnd = new Date(today.getFullYear(), 12-1, 31);
var upcomingBirthday = new Date();

upcomingBirthday.setDate(birthday.getDate());
upcomingBirthday.setMonth(birthday.getMonth());

if (upcomingBirthday <= today) {
upcomingBirthday.setFullYear(today.getFullYear() + 1);
}

Xrm.Page.getAttribute(“new_upcomingbirthday”).setValue(upcomingBirthday);
}
}

Step #3: Send E-mail Workflow

This workflow will send the e-mail on the contact’s birthday.

1. Create a Workflow for Contact with these triggers:

– On demand
– As a child workflow
– Record is created

2. Set the scope of the Workflow as appropriate.

3. The Workflow should have the following structure:

· Wait until Contact.Upcoming Birthday is today

· Send the Contact an e-mail wishing them a happy birthday

· Increment the Contact.Upcoming Birthday by a year

· Call itself as a Child Workflow (creates a loop)

How do I do that?
Follow these steps:

1. Create a new Workflow for the Contact entity (click Settings, Workflows, and create a new Workflow). The following Workflow triggers (events or actions that will start the Workflow) should be selected:

a. On demand – clip_image001[4] will appear on the Contact form and grid. This button allows the Workflow to be applied manually. If there are existing contacts that have not yet had their Upcoming Birthday set, you can apply the Workflow using this button.

b. As a child workflow – Allows the Workflow to continue to call itself on annual basis using a Start Child Workflow step.

c. Record is created – Workflow should run when the Contact is initially created.

2. Set the Scope of the Workflow to the appropriate level (does not affect the On Demand trigger).

a. User: Workflow will only trigger on records with same as owner as the Workflow.

b. Business Unit: Workflow will trigger on records owned by any user in the same Business Unit as the owner of the Workflow.

c. Parent: Child Business Units: Workflow will trigger on records owned by any user in the same Business Unit (and any child Business Units) as the owner of the Workflow.

d. Organization: Workflow will trigger on records owned by any user.

3. Add a Wait Condition step and configure the step.

a. Select Workflow from the entity list (first drop-down list).

b. Select Timeout from the attribute list (second drop-down list).

c. Select Equals from the operator list (third drop-down list).

d. Select Upcoming Birthday from the Form Assistant

e. Save the configuration

 

Note: Derik Stenerson has written an article that gives more detailed instructions about the Wait Condition step, and some of its other uses, called “Turning Inaction into Action”.

4. Add a Send E-mail step and configure the step.

a. Select the To field and click the attribute drop-down list in the Form Assistant.

b. Select Contact from the attribute list, click Add, and then click OK.

c. Once you have configured the rest of the Send E-mail form as needed, save the changes.

Note: If the Contact does not have an e-mail address the Workflow will fail. As an extra precaution you may want to add a Check Condition that checks if the Contact’s e-mail address has been set.

5. Add an Update Record step and configure it.

a. In the Additional Fields tab, select the Upcoming Birthday attribute.

b. In the Form Assistant, select 12 from the Months drop-down list

c. Select After from the drop-down list under Months

d. Select Upcoming Birthday from the attribute list (second drop-down list under Look for)

e. Click Add and OK

f. Save the configuration

6. If you have not done so, click the clip_image002[4] button to save the changes to the triggers.

7. Add a Start Child Workflow step. Using the Lookup control, select the current Workflow (so that Workflow is calling itself). Since I called my Workflow “Recurring Reminders – Send E-mail”, I will select that item from the list.

8. Publish the Workflow. Don’t forget to run this Workflow on existing contacts.

Now new and existing contacts will receive e-mails congratulating them on their birthday.

You know you want to comment:

Website Powered by WordPress.com.

Up ↑