loader

For this tutorial in video form, click here

If you know how to add records and fetch existing records, the next step is to update an existing record. Let’s learn how.

The Documentation

To access the documentation, open up your CRM. Under API, click Record API>Update Specific Records.

Next, click “Deluge” on the right.

Scrolling to the right you can see the syntax is crm.update, the module name, the record ID, and then the data that you want to use to update.

There’s also a method Upsert Records. The documentation for it is directly under Update Specific Records. Upsert will insert if there isn’t already a record in the CRM – if there is (based on checking the email address, phone and other unique fields), it will update the existing record.

For example, email address is normally out-of-the-box a unique field. If there’s an existing lead with the same email address that you supply, it will (rather than adding a new lead) update the existing one using the email address that you supplied as the key to search for. We’ll show you how to use both.

Update

First of all, let us update a lead.

This is how to write the code. Let’s click “Save & Execute Script” at the bottom. After testing it out with a Lead ID, we can see it’s sucessful.

We should find now that our Prospect will have an email when it didn’t have it before.

if we go to the timeline, we should be able to see that there was an update.

Success!

Upsert

Now let’s try out Upsert. Simply modify line 8 to this, and you’re good to go.

Here, you can see our function has operated successfully:

And here we can see the updated info (in the first name):

Rather than inserting, it has updated an existing one.

Let’s do one where it will insert. In the code we went ahead and changed the email to an address not connected to any lead. After executing, we can see a new lead has been created. It’ll even give us an ID to paste into our URL for the new lead:

You can see we’ve got a new lead.

This illustrates how Upsert works.

Hopefully that helped you to understand how to use Update Record and Upsert.

For this tutorial in video form, click here