Send email notification when someone logs case activity - dynamics-crm

Our company wants to know when the case activity is 75% of the original estimated hours.
However, I think that might be a bit of a tough call.
So, can someone explain how to send an email notification from Microsoft Dynamics CRM when someone logs any kind of "case activity" against a case? I am happy to use .NET code if necessary.

Create a workflow against the 'case activity' entities, add a condition to the workflow to only send an email when the the 'case activity' is related to a case. E.g. regarding case contains data.

I would prefer a Plugin for this kind of thing because you can do a lot more within a Plugin's context.
This is what I would imagine:
Whenever an activity record is created/modified/deleted; if it is regarding a case, the plugin will execute:
Get all regarding activities for the case
Sum up the Duration
If the Duration Total is 75% of the Case Estimate then fire a
workflow
The workflow will then be configured to send an email. By combining the plugin with a workflow, you allow the email to be configurable if the wording/recipients/from needs to change in the future.
I would probably also pass in the 75% as a configuration setting to the plugin so that this is also semi-configurable (doesn't involve code - but you'd need to modify the plugin registration).
The plugin would need to cater for
New Activities being added
Existing Activities being edited (Duration and/or State changes)
At first I thought you would also need to handle Deletes, but that would drop the Duration below the 75% so you wouldn't need to send an email.

Related

How to avoid synchronous and use asynchronous effectively?

Intro
Hey, my question is kind of hard to explain so I apologize in advance.
Question
I'm trying to implement microservices for our ecommerce and I'm having issues on how to respond to a request when the actual logic and data needs to be determined by other ( 2-3 ) services.
In order to make it easier to understand, I'll give an example.
Lets say User A is trying to buy a product. after clicking on "check out" button these steps should happen.
Flow
Request comes in:
Ecommerce service:
Check if product has enough quantity in inventory.
Publish an event indicating a new order has been created. order:created
Anti Fraud service:
Receives order:created and checks whether the user is a fraud or not
Publishes an event indicating the check was successful. check:succeed
Payment Service:
Receives check:succeed and creates a url to the gateway.
Sends the gateway url to the user. (( this is where the question arises ))
Since all of these steps are asynchronous, how do I respond to the request?
Possible Solution
After the user has requested to checkout, the ecommerce service creates an order and responds immediately with the orderId of newly created order, on client-side the user has to request periodically and check whether the status of order is PENDING PAYMENT, in order to achieve this, the payment service needs to publish payment:created after the order has been approved by the system and then ecommerce service can update the order.
My solution works, but I'm really new to microservices and I want to ask from experts like you on how to implement this in a better way.
I really appreciate if you read this far, Thank you for your time.
your flow is a synchronous process. you need a result from previous step so it has to go step by step.
point of system view:
what matters here is: "how to handle steps?". which reminds me SAGA design pattern (specially when you need a rollback handling) but in general there are two types (choreography and orchestration). The choreography describes the interactions between multiple services, where as orchestration represents control from one party's perspective.
for simplicity you can implement the command pattern or use EAI(Enterprise Application Integration) tools like Apache camel to handle message between endpoints according to the flow.
if you have a lots of visitors it's also better to use a queue between endpoints whether with an orchestrator or without.
point of user view:
when a user click to checkout their cart. they don't expect many of steps or to do more than just wait. as keeping the connection open for response is not a good idea maybe a loader and a periodically ajax call behind it is quite enough while there are other solutions like push notification (then you can consider on fire and forget mechanism).
Your workflow for handling a request as it is defined is totally synchronous. Each step depends on the previous step, and cannot start until it finishes. However, second step does not seem to need data from the first step, so actually they could be executed in parallel.
so, what can be done is start both of them:
Check if product has enough quantity in inventory.
Checks whether the user is a fraud or not
then
wait for response and if both are ok, then creates a url to the gateway. and sends it to the user.
You can create a camel route or any other tool that implements EIP to achieve the functionality

How to create a custom notification in Dynamics

I am looking in to creating a notification function in Dynamics 365, and to find the best solution, I have began with searching for the possibilities (Javascript/C#/All others). Example: Sending a user a notification that a new lead is created.
Edit:It should be generic and easy to add a new notification. So maybe it should be a workflow step, or connected to an entity.
Email notification is already integrated in Dynamics 365
Microsoft Graph has a Notification possibility (Only in Beta)
https://developer.microsoft.com/en-us/graph/graph-explorer#
Create a custom entity which. And on dashboard add a Web Resource (Javascript) that looks through the entity to find if there are any Records on the current user. If so make a popup.
Use Chrome extension to notify user.
(Example: https://community.dynamics.com/crm/b/bruce365usingdynamics/archive/2017/11/02/announcing-365-notify)
Is there any other possibility you know of?
Or do you have any experience with any of these. What one should go for or not.
Your best bet is Dashboard with Posts in Timeline/social pane. This just need couple of configurations like Post rule, Timeline embedding in Dashboard & user training.
Activity feeds
Activity Timeline
If not, timely workflow or MS Flow to send a digest notification.
I would say if you wish to go code less solution then use Workflow
and place trigger as you wish. Send an Email to Either team or
particular user from this workflow. Just set regarding in Email as
Account or Contact or any entity from which you have an Trigger. By
this way You can see all these notification in your Social pane
timeline as well.
If you need some custom logic, Use plugin but in turn call a
workflow which will be onDemand workflow and this will only be used
to send Email.
There can be different Ideas as well. But we have this in place on one of our productive system and it fulfilles requirement of Notification very well.
Since you specifically want to interact with users within the CRM system, there are a number of simple approaches:
Task Queue (Passive) -
Create task records within CRM (these can also sync to Outlook if you want to get fancy). Users review a queue containing all of their tasks. You can similarly assign tasks to teams of users. I recommend this approach for CRM oriented users who have a number of different tasks.
View/Report/Dashboard (Passive) -
Create views of records requiring action. Users then review these views on a regular basis. I recommend this approach for non-time sensitive tasks, and tasks executed in bulk across many records.
Email (Active) -
Create a workflow with a Send Email step. This is easy to do but could generate a lot of emails which the users may then ignore. I only recommend this approach for rare notifications, or those requiring urgent action.
Emailed Reports (Active) -
A hybrid of the second and third approaches, there are third party solutions that will email view results to users on a scheduled basis. This would be my recommendation if you want an active approach without spamming users constantly. These are easy to install and configure and entail a small cost.
In addition to the many viable options offered above (a few of which I was unaware), if the user's daily responsibilities include working with Leads, you might want to keep it super simple - create a My New Leads view and instruct them to check it throughout the day. You could even place this view on a dashboard, making your option 3 redundant.
If the user rarely needs to concern themselves with Leads, the need for a notification strengthens. Assuming that the Lead volume will not flood their inbox, in the interest of simplicity you could start with a workflow email notification.

Slack logon trigger

I want to create something in Slack that sends a message (starting by calling someone with '#') to a channel when specific users login. I've checked ifttt and zapier. I also checked the slack api to create something myself, but I couldn't really find anything usefull.
Anyone has any ideas?
Slack does not track user login or logoff in a traditional sense. Instead, users are always always "logged in" and available to receive messages once they have joined a team / channel.
There also is the concept of "presence", which is related, but not the same thing. User presence can change multiple times during a few minutes, e.g. if the user is on a mobile. I am guessing you would not want to send the user your message that often.
Still you can poll the presence information of a user with the API users.getPresence , which could be used to implement a script that polls this information on a regular basis and send your message. You also want to filter out presence changes below a certain duration threshold.
Keep in mind though that the rate limit for API methods is 1 per second. So depending on how many users you have in your workspace there will be a significant delay between the user becoming "present" and your script being able to send the message.
There is a workaround for that to have a google sheet as a database for the users and you can trigger by day once and timestamp it.
So the best trigger is a private message or public and you can use filter when mentioning or signin or signout it depends on the trigger word then you pass the filter since zapier won't count your zaps if you used fiter as a second step.

CQRS Task UI - Responding to underlying changes

Been moving into some task oriented UI as a part of my CQRS implementation.
The problem is I have come across the need to update additional properties in my UI as a result of a change made by an initial command sent from the same UI.
My case is different but here's an example...
eg. CommandA Add item to cart resulted in the following events (which all need to be reflected on the UI)
change to store inventory
add item to shopping cart
change total with sales tax
What's the best way to handle this without baking my business logic into my UI?
return a list of resulting events that were performed as a result to the initial command?
return a DTO that reflects changes
other ideas?
I haven't completed it yet, but my idea is to use a Hub from the SignalR framework and subscribe to events and act on them. As long as you can correlate user guids with the connected user guids in SignalR, you can send updates to the correct client and even detect if they still are there.
SignalR isn't that mature yet but the tests I have done works pretty good.
I use it with Knockoutjs and I just update my view models and call functions.
Do those events really need to be reflected in the UI? Consider Amazon, who display "you just added foo to your cart", but don't show any of those other details. That might save you from the problem by redefining it away.
Otherwise, why are you afraid of business logic in the "UI" - specifically, why not include some components from the service that owns each part of that system in your client, and give them the responsibility of doing whatever local updates are appropriate?
In other words, having part of the logic from your sales tax service running in the UI is fine. You (obviously) don't trust it with the billing calculations for tax, but you can totally trust it to do the right thing for the client.
The other advantage of that model is that you get instant feedback for the user, or at least the option of showing instant feedback, without baking more business process knowledge into the client.
For example, recalculating shipping takes time to do - if your client shows a spinner over that, something needs to know to trigger that showing up, right?
If your UI knows that, it has embedded business process around the process. On the other hand, if you have code that is part of the "shipping" service, you can change what response occurs in the client by changing only the one service...

Changing the sender of a Dynamics CRM e-mail in a plugin?

So, here's my situation. We have a department that needs the ability to use queues in CRM 4. They also need the ability to reply to e-mails that come to that queue from their department e-mail address. (So that any customer responses will go back to the queue to be handled by agents)
I originally was going to build a JavaScript customization that inserted a checkbox that said "Send From Business Unit". Toggling this would look up their department user based on the e-mail address on the Business Unit. I successfully got this working (as a concept), but found that actually sending triggers the dreaded "CrmCheckPrivilege failed."
Which is good, because that means CRM is actually enforcing security.
So my problem? I have no idea how to replicate this functionality and it's a must have for this customer group. Is there anyway to modify the e-mail after it's already gone through security checks via a plugin? Perhaps a pre-stage send plugin?
I want to be reasonably certain of success before I commit a lot of time to this solution. I'm also open to any other ideas too.
Thanks in advance,
Clif
Well, first, a "CrmPrivilegeCheck failed" can always be fixed by adjusting the user's roles and giving him the appropriate privilege (the privilegeId is always returned in the exception but may not be shown in the particular error dialog you are getting) and level, but this may not be wanted by the department.
A solution we have used is just slightly different from yours: Do not send the mails through another user, but through the queue. Queues can also be eMail senders in MSCRM. The queues should already have the correct eMail addresses set in order to work properly with the eMail router. Set up a way to determine the correct queue (like a field on the systemuser entity or a hardcoded queue name in your JavaScript) and set the from lookup accordingly in your JavaScript. That way the eMails will be sent using the name and address of the queue, so any direct replies will always have that queue as the recipient.

Resources