Background
Workflows and dialog processes in CRM 2011 (and CRM Online) allow us to send emails to email-enabled records (such as contacts, accounts and users). In the event that the email-enabled record does not have an email address, the process will fail with an exception (workflows remain in waiting state, dialogs throw the exception):
Unhandled Exception:
System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault,
Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35]]: Object address not found on party
or party is marked as non-emailable
My scenario
In many scenarios, faulting the entire process because an email couldn't be sent is heavy-handed (equally I accept that there are many scenarios where this behaviour is desireable too). As an example, if I am creating and updating many records as part of a large workflow and simply wish to send a simple, courtesy confirmation email at the end of the process, I do not want the entire process to fail simply because this final step could not complete. I can add a simple conditional statement to my workflow to check presence of address prior to the send-email step. This works but I (or more specifically, my users) need to remember to do this for every single email step that is created.
Theoretical solutions
Ideally, I would have a child workflow that would accept an email object as input and then I'd run a little check to confirm that there is a sender and recipient before sending the email. If data is missing I could either silently fail the sub-process or invoke different logic such as email the originating user or write an error record.
Howver, given the following....
Custom workflow assemblies are still not supported in CRM Online
Workflows do not accept incoming parameters
Even dialogs don't support an "email object" as an input parameter, or an array of values (e.g. for recipients) as an input parameter
Child dialogs do not return control to the caller after completion
...I am struggling to conceive of a pattern or solution that would effectively allow me to avoid the users having to remember to put a hard-coded check in every workflow or dialog that they create (to check for the presence of a recipient email address).
Ideally I want something like a generic child-workflow that takes the email object (or a serialisation or other representation of it), makes the checks and sends the email if it can.
Over to you
I've tried to design a custom solution but it quickly gets over-engineered (plugins on system entities etc). Otherwise I can't see a way of avoiding putting the onus on the users. Has anyone else encountered a similar requirement and better still, devised a solution?
Well I can think of a pretty straight forward solution.
New field on email - "Auto Send", bit, default No
New workflow - Create of Email, If "Auto Send" == Yes && Send contains data && Recipient contains data -> Send Email in context
In all your other workflows, instead of using the "Send Email" action, use the "Create Record" action to create an email record, populate the email as normal, but also populate the "Auto Send" field.
This way users can pretty much create an email as normal, but you get to use a single workflow to perform validation logic and actually send it.
Related
I am developing a small REST API. As I got into analyzing all the possible failure scenarios, which I have to handle to create a reliable and stable system, I went into thinking about how to make my APIs atomic.
If we take a simple case of creating a contact through the POST API.
The server gets the POST request for the new contact.
Creates the contact in the DB.
Creates a response to send back to the client.
The server crashes before sending the response.
The client gets a timeout error (or connection refused?)
The client is bound to think that the contact creation has failed, though, in fact, the contact was in the DB.
Is this a rare case we can ignore? How do big companies deal with such an issue?
To handle this, you should make your write APIs idempotent i.e. If the same operation is executed multiple times, the result should be same as the operation was done only once.
To achieve this in your current example, you need to be able to identify a contact uniquely based on some parameter, say emailAddress. So, if the createContact is called again with the same emailAddress, check in the DB if a contact already exists with the emailAddress. If so, return the existing contact. Else, create a new contact with the emailAddress and return it.
Hope this helps.
If the request times out, the client should not make any assumption about whether it failed or succeeded.
If it is just a user making a request from a web form, then the timeout should just be exposed to the user, and they can hit the back button and check whether the operation succeeded or not, and if not they submit the request again. (This is fine as long as you always keep a consistent state. If your operation has multiple steps and fails mid way, you need to roll back.)
However if reliable messaging is important to your application you will have to use a library or build your own reliable messaging layer. This could work by having the client assign a unique ID to every request, and having another request that lets you check the result of that request ID later. Then you can do automated retries but only where necessary.
I have reviewed all the past questions as well as scoured google results, but I can't find a good answer to this.
In our MS Dynamics CRM 2016 Cloud implementation, we have added email notifications to the owner of a Lead, or Opportunity, based on certain events. Sometimes the owner is a Team, and in those cases, we want to avoid sending to the team (it causes the workflow to get stuck in "waiting for retry based on error").
I added a qualification to all the workflows to say: If OwningUser.PrimaryEmail Contains Data ...
My theory was that if a user were associated with the Owner field, this would pass (all of our users have primary emails except service accounts), and if a team were associated, it would fail. However, that is not happening - it is still trying to send the email and failing.
I was concerned that it could be an issue if no user were assigned and the system tried to reference a null value.
However, I can't see another way to do this and no one I've talked to seems to know either.
Try adding a condition like this. This should hopefully tell you if the owner is populated with a team record, if not then you are safe to send the email.
Is there an email service that allows you to nicely query your own database to create the recipients list? The issue is that we do tons of specialized user segmentation to create lists of recipients. Trying to keep our database in sync with the email-service's database is risky and fraught with potential issues since user data will be updated frequently in multiple ways. But we still need the powerful features of a service like SendGrid or Mailchimp where such as A/B testing, open & click-rate reporting, WYSIWYG template design, etc.
My pipe dream is to have a service like Sendgrid or Mailchimp, but when it asks you who to send the email to, you specify parameters that you've created yourself. It sends these parameters to your server, and your server (using a little code that you've custom-written), performs a query on your user database and sends the recipient list back.
Does such a service exist?
You can do this with SendGrid, by specifying an external URL as your recipients input method.
When specifying the external URL you may select "Activate Dynamic Mode". Dynamic mode checks the URL when a Marketing Email is scheduled/sent, and updates the list accordingly.
Knowing this, you could specify an external URL whose parameters control a database query. This database query would eventually resolve to a CSV which SendGrid would process at send time. Thus removing the need to keep two databases in sync.
N.B. Dynamic mode has been known to have some problems if you specify additional columns in your csv (beyond name,email). This is slated to be fixed, however, as of this answer it has not been. If you create the list at send time, this problem will not occur.
I need solution for the following:
1) Customer places order
2) Store owner recieves email WITHOUT price info (e.g. packing list)
What files do I need to edit (I've read lots of posts and they don't seem to mention the file paths).
Thx
Two possible ways to achieve that:
You can create a model rewrite for the class Mage_Sales_Model_Order and override the function Mage_Sales_Model_Order::sendNewOrderEmail by sending an email to the shop owner using a different template
You can set the configuration entry "Sales Email/Order/Send Order Email Copy To" to nothing (so that the shop owner doesn't get the same email as the customer), and implement an observer catching the event sales_order_place_after. In the observer function you implement sending of an email to the shop owner using a template without the price info.
I know I had a hack for it ... and then I don't have it anymore. I went through everything I could and right now, we're CCing ourselves the customer notification email. As soon as we're done with our site upgrade, I'll have to readd my hack. I'm pretty sure it's in app/core/Mage/Sales/Model/Order.php possibly in public function sendNewOrderEmail()
See this pic:
I remember hard coding in a file after the customer notification was sent, we sent another one to admin but hard coding the template ID for the transactional order notification email to 8. Now, somehow, I'm doing it the "right way" but have no idea how I'm triggering this transactional email to ALSO happen with the customer order notification.
Make your custom module in that module just send a event after "sales_order_save_after".
Catch this event in observer file and put your custum coding on observer.
Read this
I'm using rails 2 for this app, with ActionMailer, but this is a general question about emails.
When we send out emails, i save a record corresponding to the email in a database table. I'd like to keep track of whether people have read the emails, and am wondering the best way to do it. On initial googling, it seems like i've stumbled into an ongoing battle between spammers and email clients!
My first thought was to use the "read receipt" header, but i know that this isn't supported by a lot of clients and is therefore unreliable. After that, i read of the tactic of including an image in the mail, and of detecting that image being loaded. I was thinking that i could put a parameter with the email record's id in the image url, so that when i get a request for that image i can see if it has a (for example) email_id param and if so, mark the corresponding email as having been read.
But, then i remembered that many clients are wise to this tactic and specifically ask the viewer of the mail if they want to display images. Obviously they might say no.
Am i right in thinking that i can't pull in other resources, such as stylesheets, in my mail? Because if i can pull them in, i could do that same trick but with the stylesheet rather than an image.
Grateful for any advice, max
Externally-hosted stylesheets are generally treated the same way as images. The client will not download them without prompting the user, if that works at all with HTML-formatted emails.
One thing to consider- you're looking to determine whether the email was read, not necessarily just received, right? Format your email so that it can't be easily read without viewing the images, and include a "view in browser" link at the top. Track image and page-format views and I think you'll have a fairly reliable way to measure actual reads.
Bit late on this, but we've got a similar problem.
We're tracking the links to our site that are included within the email. We're doing this by, like you, having a DB record per email sent out. We've generated a unique hash key per email and are including that as a parameter on all the links included in the email.
We simply then have a before_filter that looks for the parameter and records the fact against the correct email record by using the unique hash to identify the correct one.
We use a unique hash key (rather than the DB's primary key) just so it is a little bit more secure / reliable.
Obviously this method only helps us track the clicks our emails have generated (and not if they've been read) but it is still useful as we can see which of ours users has clicked on which links.
We are having major problems with this as well.
We have task wek portal, where users create tasks (like paint my house) and then we invite painters to give the task creator an price on painting his house.
For that we had a very advanced email system, that sends an invitation and if they accept the invitation we send them the contact info of the task creator.
We need to be able to track if the email was opened, and then once it's opened, we know that the company got the contact info, and we can now send another email to the task creator, telling them that they can expect to be contacted by that company.
The problem is that tracking if the email was opened is not reliable at all. There are different systems for this like msgtag (which does not support a wide range of mail clients like yahoo and other major clients) and our email API client (elastic email) even offer some API call back functions to tell us if each email was opened or bounced or whatever. But again, it's not reliable. To track if it's open, elastic email just includes a 1x1 px image and track if it's opened. So if people don't click "show images in this email" it's not tracked as opened.
So basically we are down to two options.
Have vital portions of the content printed on images, that they have to view to get the info we want to track if they got (in this case contact info)
Just have a link in the email "click here to get the contact info" and then track if that is clicked.
So in conclusion, the "track if opened" is totally useless and unreliable, unless you can fully control which email clients your recipients are using and how they are using them (like if they are all your employees or something).