Attaching a copy of an email alert in Salesforce

Standard

How long has it been? A long freaking time!
Long timeBetween summer vacations, coaching soccer and cub scouts, there has not been much idle time for this boy to blog, which stinks because there has been so much fun stuff figured out!

But, here I am, eating a turkey sammich, listing to some EDM on Slacker Radio and trying to get a blog post cranked out for you all.

What I am going to blog about is an annoyance that has been going on for quite some time… the issue of workflow email alerts. In fact, this idea is over 5 years old!

See, when you build out an email alert and it fires…well…it just fires. You can do a work around that involves carbon copys to an email to salesforce box or creating activities, but those workarounds are either not scaleable or they don’t give you much more information than “this email was sent!”.

But, I did find a work around that is scalable using my favoritest thing ever, flows*. Now, did you see that little thing there? That Asterix? Yep, that is there for a reason. It is there because I wrote this out using flow triggers. I am sure you can do this with process builder, but I am just documenting the flow trigger function here. I like process builder, but in this case, I just need to crank something out quick, so I am using triggers.

The “Too Long; didn’t read” version is this. I created a flow that runs via the workflow (remember, I am using flow triggers!). When that flow trigger runs, it will do two things. It will send off the email alert AND create an emailmessage record. Yeppers, I said create an emailmessage. What I have found is that within salesforce you can create an email record through a flow and it will happily sit there. The trick is that you will need to pass the record ID from where you are starting and use that ID for the “parent ID” field on the emailmessage record.

This is a good jumping off point if you want to venture forth and tinker around yourself. For those of you that want more details, here ya go!

My assumptions at this point are that you are comfortable creating your own method of running this flow. As long as you can pass variables over from the record, you should be good to go. This flow only has two elements. The email alert (which is already built) and the record create for the email message. There are a bunch of things you can build out when you create the email message, but I am just going to cover the basics.

  • Parent ID – this should be the record you want this emailmessage living under. In my case, it was, well, case.
  • Status – Status is a funny one. It is displayed in plain English but the value is actually numeric. In my case, I am recording a copy of a sent email, so I used a status of 3, which is “sent”.
  • EmailMessageBody – An interesting thing about this method is how the text is displayed. You will actually be creating the emailmessage.body by using the field “HTMLbody” and to make it so the text looks nice, you will need to do the following:
  • Create a text template called “LineBreak”. This text template will just have the HTML value for break “<BR>”

Line break

  • Create a text template called “Email body”. Enter your data and insert the text template “linebreak” wherever there should be a line break. If you need to get values from the parent record, insert them here. I choose to pass them all over via the flow trigger, but you could just as easily do it with a requrery.

Linebreak being used

The end result is that the emailmessage you created via the flow will have a similar look / feel to the email that was sent out via the alert. Actually, it will look way more like the Text version, but really the point is to have this copy not so much to look pretty.

As I said before, I will leave the method of running this flow up to you, so let’s talk about the results.

By doing this, I was able to get a copy of the alert email attached to the parent. I was then able to remove the activity creation on the workflow since that was how we were noting that an email was sent out. The email copy is an actual copy, so we know what was sent out, which you couldn’t do through the activity. As an added benefit, running this via the flow allowed me to do some extra shenanigans that you really cannot do through a workflow, like running queries on other objects and adding them to the email.

The last benefit is crazy obvious, this is a LOW maintenance function. If a new value is added to the email alert, I (or another admin) just needs to add it to the record creation function…no dev time needed!

As always, let me know if there are questions / comments

 

andrew

 

 

Advertisement

Automagically create tasks from templates in Salesforce!

Standard

If you are like me, everyday upon waking up, you are craving coffee. This craving requires action and also requires a set number of steps that will repeated as long as this craving is happening (Hopefully, forever and ever). If I were to map this out, it might look like this:Tasks to Coffee

The act of me waking up will prompt a series of tasks, and this is something that is repeatable EVERY TIME.

Now, apply this to your users. How often will the user be DOING something that requires them to CREATE a task or series of tasks? Here are a few examples I could think of:

  • After closing a deal, follow up tasks are scheduled for 30 / 60 / 90 days out
  • After contacting a lead, follow up tasks are scheduled
  • After losing a deal, create a set up follow up tasks

The key to this exercise is identifying ACTIONS that will require a set of tasks to be created. This is the challenge that I decided to take on with my Salesforce BFF visual flow and my Salesforce Frenemy Process Builder. The idea was that when a case meets a certain criteria, a series of tasks will be created…and is this wasn’t challenging enough, I decided to kick it up a notch and design the functionality in such a way that the tasks are not hard coded but actually templatized.

Here are the ingredients to this functionality:

  • “templitized” tasks
  • A flow
  • A process (though, you could use a flow trigger as well)

At a high level, what will happen is that the flow is kicked off via the process (or trigger). The flow does a query of all tasks and ONLY pulls those that meet our templatized criteria. These are then used as templates for the creation of new tasks. The example below is how I built this out so that a series of tasks are created when I mark a case as “Ready for Coffee”.

Enough talking! Release the Screen Shots!

Release the Screen Shots

Step 1 – Create a “templatized” task

In this case, I note that the task is a template by placing a flag on the subject and setting the task status to completed. By setting the status to completed, you can keep the task from staying open and visible on the users home page. In the example I am building out, I am looking for a subject that ends with “!MakeMeCoffee”.

Task Template XLS

I am using the connector for this because…well…it works and I didn’t want to do it by hand!

Step 2 – Create your flow

The basics of the flow is that there is a fast look up to find your templatized tasks and put them into a Sobject Collection. This collection is then looped through with your regular loop de loop, which builds out the set of tasks that will be created. Be sure to build out a formula for the subject field that strips away the template flags,

Build Task Subject

else, well, you might end up with a lot of stuff!

Flow Magic

As usual, when I built out my flow, I built out one version that is driven off of the UI (pictured below). This way, I can do rapid testing without activating anything. After things are 90% happy, I will remove UI elements and save it as a new flow.

Step 3 – Create your process

Process builder is my frenemy…I see the potential, but am still really sore over loosing flow triggers. But, the cool thing is that we have folks out there in the Upper Echelons of Salesforce looking at our comments and reading our blogs and they are making changes and I am excited for where process builder is going! Soapbox aside, I created a process for case and set the criteria.

Criteria Logic - Process Builder

The ONLY thing this process is doing is calling the flow and passing over just enough information to run. In the past when I have used flow triggers, I tended to push over more information, but since process builder requires activate / clone / activate cycle if something goes ker-plewy (for the record, I did this cycle 7(!) times for this demo!), I have switched over to just pushing over the minimum as a variable.

OK, so the work is done, you are all set…Let’s see how this works!

Now, for the proof.

I have my case created, and I am going to check the box that signals that I would like some coffee.Ready...

As you can see, tasks are now created associated with the case.Go!

To emphasize again, the power of the template is that if I (as a user, not a system admin) wanted to change something about the tasks are created, I can do so on my own and not have to wait for a system admin. Another great benefit for the admin / developer is that nothing is hard coded except for template criteria…and even that could be made more dynamic to handle further scenarios.

Further mind blowing awesomeness is that this is NOT just for tasks on cases…it could be anywhere…or even applied to other objects!

Questions / Comments / Buy me a coffee?

Andrew

Why, Process Builder, Why! (Updated – Humble Pie Edition)

Standard

I published a blog post last Thursday and pushed it up to the Salesforce Community. I am a big fan of the community because there is always lively discussion and sometimes, like this time, Salesforce legends pop up! Shelly Erceg is way up yonder on the Salesforce org chart, so it is always fun and a bit nerve wracking when someone like that drops some knowledge on you!

SNAP!

BTW – Not the knowledge you want dropped on you!

Turns out, the documentation I had found was out of date and that in fact, there was no limitation…which means that the process builder was borking out from something I did (D’oh!).

Doh

After a quick trip to the corner for some weeping, it was back to the grind to figure out just what the heck was going on!

Well, here is the short version! I started with two actions and once that was working, I cloned the process and created the rest of the tasks (13 of them ) by hand! It turns out, that when I did that, I set the “Owner ID” on one of the tasks (number 9 to be exact!) to the case ID instead of case owner ID.

Now, I did do troubleshooting before I created the idea and subsequent blog post. In fact, this process has at this time 16 versions and I created at least half of those before I found the out of date article.

Bottom line is this…Process builder is NEW and most of us SFDC veterans will remember the teething pains that were felt when other new functions got rolled out. Heck, I remember S-Controls and the anguish that removing those caused! Process builder will get better and it is because of the dialog and openness that exists on the community and from people like Shelly!

BTW – I created a new category on my blog, “Humble Pie”, because I am sure this will happen again sometime!

Why Process builder, Why? (Humble Pie Update!)

Standard

*** Guess what? This blog post is OUT OF DATE – See this new one for the updated, humble pie, “it’s not salesforce, it’s me” edition! ****

Loads of fun today. I used the process builder to set up some really cool stuff that otherwise would have required a pretty big flow or some apex.

Basically, when a case of a certain type is created, X amount of tasks will be created as well. All was right with the world, created, activated and tested…and then…the world stopped spinning.

Workflow Action Failed to Trigger Flow
The record couldn’t be saved because it failed to trigger a flow.
A flow trigger failed to execute the flow with version ID blah blah blah.
Contact your administrator for help.Click to return to the previous page.

Huh, that is weird…maybe the email message would shed some light on this.

No help here

Move along, no help here

Sigh…Good thing I have a GIF of Batman doing a facepalm!

Batman-Facepalm

After a couple cycles of “deactivate, modify, activate, test”, and more fails with that uber helpful message, I dug into google.

There, on page 9 of the Process Builder Guide, I found the ONE dang line that helped:

“• You can add up to 10 immediate actions and 10 scheduled actions to a given criteria node.”

So, that was the root of this #whysfdcadminsdrink moment…but you know what? That is kind of crazy. I was able to save and activate a process that WOULD NOT WORK AT ALL! You would think that there would be some kind of warning or something, but if you did think that YOU WOULD BE WRONG!

So please, fellow admins, join me in voting up this idea, where process builder would actually not let you save it with a condition that would cause it to fail.

https://success.salesforce.com/ideaView?id=08730000000DlNoAAK

2 cents on Salesforce Process Builder

Standard
Quarter

OK, maybe .25 cents worth!

I started playing around with Salesforce Process builder and I figured I would give the world my 2 cents on this new functionality!

The process builder is a HUGE step forward. It is really cool, especially considering this functionality is less than a year old. If you were amazed by what you can do with #ClicksNotCode before, this will be mind blowing.

3 things I like:

  • Up to 5 decision points. Raise your hands if you have ever had to dissect a HUGE workflow with multiple gnarly logic steps…OK, this one is for you all. Stop weeping, process builder is going to help tremendously. What I like is that you can have up to 5 conditions grouped under a process that run really as separate statements.
  • Run LOADS of Actions. There is NOTHING quite a fun has building out a super awesome workflow and then rebuilding the logic so you can run an approval process #sarcasm. One place for all this stuff now!

Only one not present Make me coffee

  • Great UI. I love Visio. Seriously, love it. The UI of process builder makes documentation a snap since you can just grab a screen shot and see in pictures what the heck is going on. You know what would make this better though? A Nice “Click here to Print” button that would print out the process along with all the “stuff” with it. Yes, I used “stuff” as a technical term.

3 things I don’t like:

  • Versions are a PAIN. To be fair, this is a beef I have with Flows as well. I should be able to deactivate, make changes and then reactivate. One of the MAGIC things with workflows is that you could make a change, save it, test it and be done. With Process Builder, you have to clone, enter a new name (WHY!), save then activate. If you find something goofy, guess what, same dang process. Much like flows, you very quickly generate a TON of versions.
pain

Speak it Grumpy Cat!

  • Can’t edit an inactive version. Yep, this is another versioning thing. One of the things I particularly like about flows is that I can step into a previous version, make edits and save it. Of course, there is a warning that I cannot over write the previous version, I have to save it as a new flow or new version of the flow. Sometimes, if your versions are different enough, you have to dig in and see what you could have done differently.
  • Replacing Precision Tools. You could create a flow trigger stupid fast. You could do it from multiple screens and you could edit it after you have associated it with a workflow. Here is a corny analogy. Let’s say that you noticed you have a screw loose on a piece of furniture. To tighten the screw, you would go and grab the cool screw driver with multiple bits out of your tool box and tighten the screw. This is like using a flow trigger. Just the minimum to get the job done! If you were to do this same action the process builder way, you would grab the WHOLE toolbox which includes tape measures, hammers, pliers, pencils etc…and bring it back to the furniture. Sure, the toolbox contains the screw driver and you are accomplishing the goal, but you just don’t have to lug that toolbox around.

So, that is that. Let me reiterate again…I love process builder and I think it is a  fantastic piece of tech, but don’t take away the precision tools because the tool box is getting fancier!