Formula Builder I: Creating Your First Formula

June 15, 2016 Vivek Ravishankar

Introduction to the Formula Builder UI and How to Go About Building Your First Formula.

Video Transcript:

Hey guys, today I want to walk through just a brief introduction to our Formula Builder UI and walk through how to build a simple Formula using that UI.



1) So let’s go ahead and get started. To start, I am just logged into the Cloud Elements Console here, and I am just going to click on Formula Catalog.




2) You’ll see at this point I do not have any Formulas in my account, so let's go ahead at the top here click build Formula, and this will launch what we call our Formula Builder UI.




3) So, to get started I’d first recommend checking out any documentation in our dev portal that you can find here if this is your first time. I’m going to assume you've looked through some of that and are ready to go ahead and get started.

Let’s go ahead and give the Formula a name first. I am going to call it CRM to Email. Let’s go ahead and click go.




4) Just some background, what I want to build here is a Formula that listens for events on the CRM Element and then sends me an email with what just happened in that CRM Element each time something has changed. What I want to do first is select what type of trigger I want. So, for that Formula we’re going to want an event trigger.




5) The only property you need for an event is what Element instance you are listening for. I am going to choose Salesforce.




6) I have a Salesforce Element instance provisioned that has events enabled, so I'll go ahead and choose that and click save.




7) This will bring us to our Formula tree view. At this point, we only see the trigger as we add steps. You'll see kind of how the Formula flows in the whole tree view, but right now we just have the trigger so let's go ahead and start adding some steps. So the first step we want to add is what’s called a script step.




8) A script step allows us to write some JavaScript to go about creating some JavaScript object that will be added to our Formula context. We can then use it later on in subsequent steps. I'll first give it a name and call it “construct-email-body,” and then going to write some JavaScript that will construct the actual object that we want to use when we call our “send-email” API. Here is the JavaScript object that I want to create; it's going to have a “subject”, “to”, and “from”, and then it's going to use a few of the fields off of our trigger to give some useful information as to what just happened. So it's going to say the object type, the ID it was, and the type of event that happened, created, updated, deleted, etc. So let's go ahead and save that step and create one more step.




9) Now, this step is going to be what actually calls our “send-email” API. So that's going to be an “Element Request” step which makes an API call to an Element instance API.




10) Let’s go ahead and populate these fields. So just these first four are the ones that are required, so let's say “send-email,” I want to use the “SendGrid” Element, I want to call “POST,” and it’s going to go to the “/hubs/messaging/messages” API. The last field at the bottom that we want to fill out is actually what we want to send as part of our JSON payload, and so this is where we will go ahead and reference our previous step, and that’ll use the JavaScript that we created there. So use “steps.construct-email-body” and lets go ahead and click save here.




11) Now let’s connect these steps together. So after the trigger runs successfully, I want to construct the email body, and after the construct email body step runs successfully, I want to go ahead and “send-email.” Great, so now we have our steps all set up, and now let’s go ahead and create a Formula Instance.




12) So, just going to call it “my formula instance”, and click save. At this point we can actually trigger an event to occur from the Salesforce account, and let’s see if we get an email.




13) I’ll navigate over to Salesforce and create a new account in my Salesforce called “JoshTestAccount” and click save, and now after clicking save what should happen is an Element should come into the Cloud Elements platform. I have an Element instance tied to this Salesforce account that is listening for events and that should have kicked off our Formula instance that we created, and I should have received an email saying what just happened.




14) So let’s run over to my email. Perfect, looks like I just got a new email that says “Account with ID … was created”.




So, perfect, we have created a Formula, created a Formula instance, and we are now listening for events from Salesforce, and using a “SendGrid” Element to go about sending an email with some of the data on that event. Thanks guys!


About the Author

Vivek Ravishankar

Vivek is a Marketing Intern at Cloud Elements.

Previous Video
API Talks Webinar -

Next Video
Formula Builder III: Using Variables In Your Formula
Formula Builder III: Using Variables In Your Formula

How to Use Variables in Your Formulas