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.
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.
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
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?
This is another alternative :)
Yes, you should make your sent email as tracked one
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!
For the first question,
You can use "DayOfWeek" function in C#
For number 2:
Please refer to this link:
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.
Even if i try through plugins or messaging option, what query or code i should run.
If i use outlook to auto reply, will i be able to track that sent email in CRM?
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.
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.