Smarter Text in Flows

Standard

As Salesforce admins, I hope you have figured out that Flows can make your system super smart. I think this is a smart little hack to flows that can help make them even smarter!

Hopefully not this smart

Here is the setup. You have a flow and in this flow there is some data that is stored in variables. Because this data wants to go forth and adventure, you might use a text template to put some, well, text around those variables so that it makes sense. The text template would then be used in an email alert (just for example).

The thing is, as we all know, the minute you get the text of ANYTHING dialed in, someone asks for it to change. So, into the flow you go, modify the text template, save a new version, etc, etc, etc.

But, what if there was a better way? That question was rhetorical, since there totally is a better way.

For this blog example, I am just going to have a two screens, one as a starting point and a final screen that will substitute for the above mentioned email alert.

flow overview

No clever caption for this

Notice, there is NO text templates in this flow.

Look - No Text Templates

But, the end screen has all this text? WHAAAT?

Final Product

And, just to prove I am not pulling a fast one, here is what that field looks like…it is just variables.

and just to prove...

Instead of using a text template, I am using a text field on an object. The trick here is that you have to enter the variable technical names (Curly brackets, exclamation points) into the text field. This text field is then pulled in the flow via the record look up and will accept the values from the variables.

Really, this is acting JUST LIKE A TEXT TEMPLATE, but with the advantage being that if you want to modify the verbiage you don’t have to go through the modify / save as / activate cycle.

But, we can make this EVEN BETTER! Obviously, having to enter the technical variable name limits how many people can actually use this. But, by adding a bunch of code…LOL, just kidding. We are going to build out a formula field instead. You have to do some gymnastics to get the formatting to work, but once you have it built out, you now have a formula that will show up on the actual records itself and used just like the text field above.

formula           formula on screen

And, the end result is the same!

automagical results

 

so, what do you all think? useful? not? any suggestions? I even take requests if there is a weird question (about salesforce) you might have.

 

Advertisements

You know who likes innovating? I like innovating.

Standard

You know who likes innovating? I like innovating.

This-Guy-Jim-Halpert-The-Office.gif

NOTE – Not actual salesforce admin writing blog.

Thus, when I saw that Salesforce Seattle was hosting an app innovation workshop, I decided to sign up.

The class was pretty neat, the group brought out a SE that showed us how to build out some apps and how the new lightning interface was going to make app building EPIC.

And then, just like that, it was our turn to build an app. We separated out into teams and planned (And ate tacos!). We had 2 hours to build out an app that was mobile, had some business value and used the lightning interface….and had a clever name.

No problem.jpg

NOTE – Not actual blog writer.

My team (Fairy Godmothers) decided to tackle a problem that is all too familiar to sales teams (and ghost busters) …you know what I am going to say here, “Who ya Gonna Call”?

ghostbusters6.jpg

NOTE – Not actual team photo

Being that I have never done sales, this is all anecdotal, but the nods of both the AE’s and SE’s in the room told me that I was on to something. I have noticed that a salesperson will get on a call that should not require a technical resource and then BAM! The potential customer brings a nerd along and the hard questions start to flow. The salesperson then is left scrambling for resources, vowing to never let this happen again! The next call the salesperson goes on they invite the SE and the SE just listens in and play angry birds. On a side note, I once worked at a large company that the meetings would get so large because of this phenomenon, it would take like 10 minutes to do introductions.

Being that we only had two hours, I decided to keep this simple. No custom objects, just using the functionality Benioff gave us! So flows were used…because…well…I love flows. But seriously, using flows also gives me the ability to create advanced, code like (Dare i say, low / no code?) functionality without worrying about things like UI and, well, code.

The flow itself is not anything spectacular (two hours!). Screen Shot 2016-12-21 at 10.17.40 AM.pngIf it is launched via the app, it just pulls up a list of the users open opps. The user selects one and then is presented with a list of current active users and a selection around communication methods. Selecting email will send an email, but selecting text sends out an email using the email to phone number “hack” (is it a hack any more after it has been around as long as this one?).

However, there is one bit of fun that I want to call out (as I have done before). I pass a variable to the flow which is then analyzed. This variable is ONLY populated when a flow is launched from a record, so if this variable is populated, we would know that the flow started from a specific record. By doing this, I can build out decisions that adjust the functionality. In this case, I have two start screens, one for when the flow is launched via the app (and shows all opps) and one for when it is launched via record (and just goes right to the fairy godmother selection).

Screen Shot 2016-12-20 at 9.15.09 AM.png

“And then the running back goes around the TE..BOOM!”

By doing this, you can avoid using two flows what is essentially the same functionality.

To get this working on the individual record, you have to use a visualforce page

NOOOOO.jpeg

NOTE – this is the blog author writing code (just kidding).

because the button URL hack just won’t work as expected. You can place a flow on the record page layout, but I wasn’t able to figure out how to pass a value. If you know now, shoot me a tweet (@jok3r4o2) OR send me a message through the success community. If you are local to Bellevue, I will buy you a coffee.
Anyways, not a huge deal to create a VF page. I have documented it a few times AND by doing a VF page on a button, it allowed me to make it mobile really easy by just adding an action!

<apex:page standardController=”Opportunity” showHeader=”false” sidebar=”false” >
<flow:interview name=”life_ring”>
<apex:param name=”varSourceOppId” value=”{!Opportunity.Id}”/>
</flow:interview>
</apex:page>

Alrighty, so that is the nuts and bolts of my two-hour build. Pretty dang happy with this app and will probably put into production. But, how I would I make it better? Well, cue the Scooby Doo transition!

giphy

 

  • Show users that are logged-in. I found a really cool table when building out the flow called “AuthSession”. https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_authsession.htm This is the table that shows who is logged in and how. Now, it wouldn’t be as straightforward as just using this as a dynamic lookup, but still, the idea that you could see who was logged in before you contacted them is pretty great.
  • Finding Relevant Users. Using the power of flows, we could do some data crunching to build out a profile of a specific opp (product, competitor, etc…) and then use this information to pull only fairy godmothers who have had experience in these areas.
  • Gamify! This type of app lends itself to gamification. I would have built this out so that Fairy Godmothers got credit or went up a lead board (AKA, Dashboard) for the help that they do. If you go down the gamification path, brush up on Maslow’s Heirarchy of Needs to figure out how to reward employees.
  • Communicate in multiple ways. I am using email and text, but it would be a good next step to also post in chatter. You could also use a service like Zapier or IFTTT to post to slack.

And that my friends is that! As I said, be sure to check out an app innovation workshop. I came away excited for Lightning UI and all the neat things it can do along with a great app idea and a couple Starbucks Gift cards.

As always, did I miss anything? Do you have a great idea for an app and just need a bit of help? Find me on success.salesforce.com and drop me a line!

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

 

 

Reducing the amount of email while sending email

Standard

In my post titled “Cleaning the data that matters – and not all data matters” I finished the post up with the following:

“PS – For bonus points, create a nice email alert telling the reps their data is bad, and make it so it sends them that notice every time they edit the account OR opportunity…just put on a timer so it only sends once per day!”

To which, JaneIsaac replied:

“nice detective work. Could you share What the timer formula look like?”

Well JaneIsaac, this post if for you!

Not that type of request

I take requests…just not freebird!

The scenariois that we wanted to send out alerts if an account scored low data grade points and that account OR an opportunity related to that account was updated. After some quick research I saw that the updates were clustered, often receiving multiple updates in a short period of time. I didn’t want the alerts constantly kicking out.

So I built out a function so that prevent multiple alerts from being sent out in a given set of time. My functionality treats account and opportunity updates as two different actions, so I broke them out on this blog as such. Listing out the ingredients below and I will dissect the basic functionality after.

Must be about snack time...

Ingredients for tasty food, not tasty Workflows

For the Account alerts:

1 – Date field on Account “Data Alert Sent Date”

1 – Workflow rule for the Account Object “Data Grade Alert”:

Evaluation Criteria = “Evaluate the rule when a record is created, and any time it’s edited to subsequently meet criteria”

Rule Criteria =

Account WorkFlow Criteria

AND(
AND(Account_Data_Grade__c <>”Acceptable”,Account_Data_Grade__c <>”Excellent”),
Open_Pipeline__c < 1,
AND(LastModifiedBy.ProfileId <>” xxxxxxxxxxxxxxx “,LastModifiedBy.ProfileId <>” xxxxxxxxxxxxxxx “,LastModifiedBy.ProfileId <>” xxxxxxxxxxxxxxx “, LastModifiedBy.ProfileId <>”xxxxxxxxxxxxxxx”),
(DATEVALUE(CreatedDate)<>Today()),
OR(ISBLANK(Data_Alert_Sent_Date__c),(Data_Alert_Sent_Date__c) <> today()))

2 – Immediate Workflow Actions

All about that (Account Workflow) action Boss

1 – Workflow email alert Sendemail to “Last Modified By”

Account Workflow Alert

       1 – Field Update “Data Alert Sent Date” with Today()

Account Field Update

 For the Opportunity alerts:

1 – Date field on Opportunity “Data Alert Sent Date”

1 – Workflow rule for the Opportunity Object “Data Grade Alert”:

Evaluation Criteria = “Evaluate the rule when a record is created, and any time it’s edited to subsequently meet criteria”

Rule Criteria =

Opportunity Workflow Criteria

AND(
AND(Account.Account_Data_Grade__c <>”Acceptable”,Account.Account_Data_Grade__c <>”Excellent”),
AND(LastModifiedBy.ProfileId <>” xxxxxxxxxxxxxxx “,LastModifiedBy.ProfileId <>” xxxxxxxxxxxxxxx “,LastModifiedBy.ProfileId <>” xxxxxxxxxxxxxxx “, LastModifiedBy.ProfileId <>” xxxxxxxxxxxxxxx “),
Record_Type__c =”Open Opportunity”,
(DATEVALUE( Account.CreatedDate )<>Today()),
or(ISBLANK( Data_Alert_Sent_Date__c ), (Data_Alert_Sent_Date__c)<>TODAY()))

2 – Immediate Workflow Actions

All about that (Opportunity Workflow) action Boss

1 – Workflow email alert Send email to “Last Modified By”

Opportunity Email Alert

          1 – Field Update = “Data Alert Sent Date” with Today()

Opportunity Field Update

Taking a look at the mechanics:

I wish my cube was this cool...or that I had a flying monkey!

I wish my cube was this cool…or that I had a flying monkey!

The rule criteria’s are similar enough that we won’t have to dissect them both and since the interest is in the timer components, that is what I am going to focus on:

1)      (DATEVALUE( Account.CreatedDate )<>Today()) –  Ignore if the account is newly created

2)      But, the following situations are OK:

  1. (ISBLANK( Data_Alert_Sent_Date__c ) – The data alert sent date is Null (Never triggered before)
  2. (Data_Alert_Sent_Date__c)<>TODAY() – The data alert sent date does not equal Today()

This last line is what ensures that an alert will only send once per day. If the rule runs, (Data Quality = Poor and “Data Alert Sent Date” <>Today()), then the email alert gets sent out and the “Data Alert Sent Date” gets updated with the current day. If that record was updated ANY OTHER TIME during that day, the rule will not fire. I know I say this all the time, but what I really (Really) like about salesforce is that when it comes down to it, you can do some crazy cool stuff with zero code.

Clicks Not Code!

In other CRM’s, the above functionality takes 6 weeks and 2 developers.

 

Looking at this functionality now, I think a couple neat additions would have been:

1)      A rollup summary on opportunity.Data_Alert_Sent_Date__c (MAX), this way, you could have the account rule also looking at the last time an alert was sent out on ANY opportunity.

2)      A counter field update on the opportunity rule with a corresponding rollup on accounts. This would allow for reporting on ignored updates and thresh holding of the alerts.

But, the fun with Salesforce is the ability to rapidly prototype and tinker, so if I wanted to add in some new stuff, it is easy – peasy – lemon squeezy.

Well, hope you enjoyed this. I certainly had fun taking a look at something that was built out quite some time ago but continues to keep ticking! If there are any special requests, just let me know!