How to Use Variables in Your Formula
Hey guys, in this Formula Builder video I want to show how you can leverage variables in your Formula, which will allow you create much more flexible Formulas, and not have to hardcode Element instances or anything like that in your Formula. It allows you to create a Formula that multiple people with different Element instances or different endpoints of a given service can use and leverage. So let me walk through this and show how to do that.
1) So I'm going to pop open our “CRM to Email” Formula that we've been building as a part of the other videos, and I'm going to click on variables here.
2) So, I'm going to go about creating two variables, they’re both going to be Element instance variables. So we're going to swap out those Salesforce and SendGrid Element instances were using to be variables and we’ll actually assign those when we create an instance.
3) So first let me create two variables. The first one is going to be “crm.instance” and save that.
4) Then let's create another one and let's call it “messaging.instance” and save that.
5) And what I'm going to do is go to our trigger that's listening for events, and instead of hardcoding “sfdc”, I'm going to use a variable here, and as you can see they populate at the top, and I'm going to choose that “crm.instance”.
6) Also in our “send-email” step I am not going to use a hardcoded SendGrid instance, I'm going to use the “messaging.instance” and click save.
7) So at this point I have just moved the trigger in the “send-email” to use our variables. Now let's actually go create a new Formula instance. So, I'll call it “my formula instance” again, and you'll see we have two new values that are being asked for to create an instance. So in the "crm.instance" I'll now choose Salesforce and in the "messaging.instance" I'll now use SendGrid and click save.
8) Now I'll pop over to Salesforce real quick and actually go about updating a contact. So I’ll change this contact's phone number, click save, alright it just finished saving.
9) Let's go check my email and do a refresh here, one more time. And there we go, we got our email here just like we did before: “contact with ID… was updated”.
So what I did there, obviously same result, but now we've created a Formula that is much more flexible, and now we can have people that are using different services, different instances of, in this case, Salesforce and SendGrid, use that same Formula and just create different Formula instances. So that's how to use variables.
About the Author
Vivek is a Marketing Intern at Cloud Elements.More Content by Vivek Ravishankar