- My name is Becky Jaimes
and I'm a product manager here at Salesforce
working with the Salesforce Functions team
and today, I'm going to show you
what are Salesforce Functions
and how we can actually use them.
Salesforce Functions are event driven.
It is a fully managed
and integrated platform that extends the customer 360
data and processes with serverless, elastic compute
and that is a mouthful
and I can continue to stand here
and lecture you about all the amazing things
that Functions do
like for example, you can test them locally,
it's suite integration with the Magic integration
with LWC and Node.js,
they integration with Node.js
but instead what I'm going to do
is I'm actually going show you a demo
and I'm going to invoke and test a Function locally.
I'm going deploy it,
I'm going invoke it using Apex
and then I'm going to call in
external library from MPM
to make my development more efficient.
So, to get started,
we have here our development environment.
We have an index.ts file
and here's a description of this function.
It's going to create an account, contact,
and opportunity object
all together in a single transaction.
You're seeing the unit of work API.
So here we have the unit of work API
and we're going to create the account,
the contact, and the opportunity object
here at the end we're going commit.
So let's see how this looks like.
Let's run the Salesforce Function locally to test it out.
So we do a Function start
and we're going wait for their rate to process signals
that it's going give us.
All right, it's ready to go.
So now here in the other tab,
I'm going to run sfdx,
function invoke
and we're running the function locally
by using the scratch rq at the end
account-fx.scratch6
We're going run these.
Here we go,
we got the three new records,
the account ID, contact ID,
and opportunity ID.
And let's open Salesforce to see how this looks like.
All right, here we go.
So, we got that account object.
We also should have the contact, yes we do,
and also let's check opportunities.
And we do.
So let's deploy this function now.
Let's use function deploy.
Let's see, let's wait a second.
It takes about 20 seconds to do these.
It should be like a cooking show
that have the pre-bake thing in the oven already.
And there you go.
That's it.
Now that we deployed the function,
let's execute it from Apex.
So what we'll do is,
we're going to run
force apex execute
and note how we're referencing this file here
that has account apex execute.txt file,
I want to see what's in this file
before we execute it.
Let's open vs code
and check it out.
So, basically this is doing a system debug
to print out the result of functions function.get.
The name for function, account function,
and then with this adjacent payload,
we're going invoke it.
The payload is setting account name to account name
contact name to contact name
and opportunity name to opportunity name
for all those new records that we're creating.
So let's go ahead and run these.
So once this,
okay, it compiled successfully, executed successfully,
this is the debug message
for what was printed,
the new account ID,
new contact ID,
and the opportunity ID.
Okay, let's open up our Salesforce org now
and verify that those records were created.
So there we go
and now we have two records.
Before we only had that one record
and here's the new account with the random number
appended to the end,
the one that we just created.
But I want to give you a little sneak peak into
the power functions
and something that wasn't available to you before
the Salesforce platform.
Not only that you can test things locally
but I'm going go back to the vs code
and since our function was written in Java script,
well technically this is type script
but it's compiled to Java script.
Since it was Java script,
it means that we can also use
all the other open source packages available from MPM
and I'm going change things up a bit
and use a fetch package
and with that we're going to
reach out to an external web service
and reach our opportunity data
and it's going to return
an estimated probability
and again, this is a hypothetical example.
It's going to return an estimated probability of success
for these opportunities based off of contact name.
So we add the code,
let's go ahead and run this locally.
So we go back up
and we start it up.
And once this is done,
in a couple of seconds,
all right,
and now ready to process signal
and we're going invoke it from the other tab.
Once this is ready to go,
we're going to
check, let's wait until it's done,
okay, great, it's done.
So now let's open,
let's look at this opportunities again
that we've created
in our Salesforce org.
So the first one,
the first opportunity that we created
should have the,
here under details,
should have the default probability that was 10%
but now if we go to the new one,
the latest one we created,
if we go back to details,
note how it is 49%
and this is our custom probability
that we created
for the new record.
So that's it for the demo
that I have today.
Again, we invoked and we tested the function
in local development environment.
We deployed it,
we invoked it,
and then we leverage an MPM module
for an example purpose here.
A lot of our customers
that are currently using Salesforce Functions
for developer preview are running a ton of data,
like database operations, data validation and cleansing,
some of our customers are also
testing things with APIs
and a few customers right now are also
taking a look at pdf and image processing
and that's it folks.
That's all what I have today
for Salesforce Functions.
If you're interested
and you want to stay in touch,
sign up here to our newsletter
but if your organization is ready to help us
kick the tires and test and provide some feedback about
Salesforce Functions, reach out to your AE
for a nomination into Salesforce Functions
and I will see you there
because I am the person running the Salesforce Functions
developer preview.
So have a good day, bye.