Question Status

Suggested Answer
John Dep asked a question on 21 Jul 2014 7:47 AM

Hello,

Every time i receive any email during weekends and non business hours, i want to send an automated reply. I am trying to do this through workflow but stuck in finding the query to run. What should be my query to find out emails during the day and time mentioned above.

Reply
Suggested Answer
Phillip U. responded on 21 Jul 2014 8:55 AM

I don't think you can create a condition that checks whether a date is a weekend day in workflow.  Alternatively, you should consider a plugin or possibly handling this business case through your messaging system's rules.

Reply
Suggested Answer
Chitrarasan Duraisamy responded on 21 Jul 2014 9:12 AM

You need to query calendar to get user working hours. check this link it will help you to write your query to find user workhours

nishantrana.me/.../sample-code-to-update-users-calendar-programmatically-work-hours-in-crm-2011

Chitra


Reply
Suggested Answer
Aileen Gusni responded on 23 Jul 2014 11:14 AM

Hi, John,

I think you cannot use Workflow since workflow does not support filtering criteria until unrelated entity level, which is weekend or non business hours, are not stored in the Email entity record.

For the query, it should use SQL Query helper, so that you should create a batch scheduler accessing the CRM View using SQL Query to read the email meta, including when you receive this email, is that during weekend or not (using SQL function).

The fastest way, since you are using Outlook, right? Why you don't use Outlook feature to auto reply?

office.microsoft.com/.../manage-email-messages-by-using-rules-HA010355682.aspx

superuser.com/.../how-do-i-set-up-outlook-2010-to-send-auto-reply-based-on-the-time-and-day-of-the

This is another alternative :)

Reply
Suggested Answer
Aileen Gusni responded on 23 Jul 2014 11:14 PM

Hi,

Yes, you should make your sent email as tracked one

Read this:

niiranen.eu/.../synchronization-vs-tracking-understanding-activity-management-options-dynamics-crm

crmtipoftheday.com/.../track-emails-using-forwarding-inbox

Okay, my suggestion is now, you should create:

- a new field in the Email entity, Option set of the Day name Monday - Sunday

- a new field to store the time of the received date or to store, is it within Business Hour or not?.

- a plugin once Email is created

- write plugin code, if email direction = incoming, then using C# code, you can get the date of received email, then you can get the Day Name, right through C# Code, you also can get the time of the received date, store those values to the 2 new fields.

- Then you create a workflow

- The workflow logic is

  * If Day = Saturday or Sunday

    --> Then, create an action sending Email

  * If Day != (Saturday or Sunday),

     * Check the time whether it is within Business Hour or not.

        --> If not in Business Hours, then sending Email

I think this is the best way rather than you create a batch scheduler.

Hope it helps!

Thanks.

Reply
Suggested Answer
Aileen Gusni responded on 24 Jul 2014 9:25 AM

Hi John,

For the first question,

You can use "DayOfWeek" function in C#

msdn.microsoft.com/.../system.dayofweek(v=vs.110).aspx

For number 2:

Please refer to this link:

msdn.microsoft.com/.../system.datetime.toshorttimestring.aspx

To create a plugin, I would suggest you to download the SDK first.

You should try to understand how to register plugin using plugin registration tool first.

Plugin is just a feature to embed additional logic in certain CRM Action and messages, such as onCreate, onUpdate, onAssign, etc.

In this case, you will need only onCreate.

Try to download the SDK and read the sample code form plug-in.

Hope it helps!

Thanks.

Reply
Suggested Answer
Phillip U. responded on 21 Jul 2014 8:55 AM

I don't think you can create a condition that checks whether a date is a weekend day in workflow.  Alternatively, you should consider a plugin or possibly handling this business case through your messaging system's rules.

Reply
Suggested Answer
Chitrarasan Duraisamy responded on 21 Jul 2014 9:12 AM

You need to query calendar to get user working hours. check this link it will help you to write your query to find user workhours

nishantrana.me/.../sample-code-to-update-users-calendar-programmatically-work-hours-in-crm-2011

Chitra


Reply
John Dep responded on 22 Jul 2014 1:50 AM

Even if i try through plugins or messaging option, what query or code i should run.

Reply
Suggested Answer
Aileen Gusni responded on 23 Jul 2014 11:14 AM

Hi, John,

I think you cannot use Workflow since workflow does not support filtering criteria until unrelated entity level, which is weekend or non business hours, are not stored in the Email entity record.

For the query, it should use SQL Query helper, so that you should create a batch scheduler accessing the CRM View using SQL Query to read the email meta, including when you receive this email, is that during weekend or not (using SQL function).

The fastest way, since you are using Outlook, right? Why you don't use Outlook feature to auto reply?

office.microsoft.com/.../manage-email-messages-by-using-rules-HA010355682.aspx

superuser.com/.../how-do-i-set-up-outlook-2010-to-send-auto-reply-based-on-the-time-and-day-of-the

This is another alternative :)

Reply
John Dep responded on 23 Jul 2014 12:15 PM

If i use outlook to auto reply, will i be able to track that sent email in CRM?

Reply
Suggested Answer
Aileen Gusni responded on 23 Jul 2014 11:14 PM

Hi,

Yes, you should make your sent email as tracked one

Read this:

niiranen.eu/.../synchronization-vs-tracking-understanding-activity-management-options-dynamics-crm

crmtipoftheday.com/.../track-emails-using-forwarding-inbox

Okay, my suggestion is now, you should create:

- a new field in the Email entity, Option set of the Day name Monday - Sunday

- a new field to store the time of the received date or to store, is it within Business Hour or not?.

- a plugin once Email is created

- write plugin code, if email direction = incoming, then using C# code, you can get the date of received email, then you can get the Day Name, right through C# Code, you also can get the time of the received date, store those values to the 2 new fields.

- Then you create a workflow

- The workflow logic is

  * If Day = Saturday or Sunday

    --> Then, create an action sending Email

  * If Day != (Saturday or Sunday),

     * Check the time whether it is within Business Hour or not.

        --> If not in Business Hours, then sending Email

I think this is the best way rather than you create a batch scheduler.

Hope it helps!

Thanks.

Reply
John Dep responded on 24 Jul 2014 8:49 AM

The suggestion looks good but before i try this, few questions come in my mind:

-lets say, i create day field with option set values as monday-sunday.Now, how will the system populate the day field with values like sunday, monday or any other day.

-if i create time field, how will the system populate this time field of the time when the email was received.

-since i am new to plugin, i would need some more help on how to register the plugins.

Reply
Suggested Answer
Aileen Gusni responded on 24 Jul 2014 9:25 AM

Hi John,

For the first question,

You can use "DayOfWeek" function in C#

msdn.microsoft.com/.../system.dayofweek(v=vs.110).aspx

For number 2:

Please refer to this link:

msdn.microsoft.com/.../system.datetime.toshorttimestring.aspx

To create a plugin, I would suggest you to download the SDK first.

You should try to understand how to register plugin using plugin registration tool first.

Plugin is just a feature to embed additional logic in certain CRM Action and messages, such as onCreate, onUpdate, onAssign, etc.

In this case, you will need only onCreate.

Try to download the SDK and read the sample code form plug-in.

Hope it helps!

Thanks.

Reply
John Dep responded on 24 Jul 2014 12:31 PM

well for now, i need to first learn plugins and then your suggestions might be useful and easy to understand. i ll come back to you if i have further doubts.

Reply