Join The Community Sign Up For Club Zenatta

Article Read Time:

3 Min

Stay Connected

Getting Started With Deluge – Write Data

In the final video of our Getting Started With Zoho Deluge series, Greg teaches us how to do the final step of writing data. Make sure to check out the previous videos on Reading Data and Editing Data!

Key Takeaways

Getting Data Onto The CRM Record

As you’ll remember in the last lesson, we got the lead record by ID, edited the First and Last Name fields, and counted the number of open tasks associated with the lead record. Now that we’ve gathered our data, we need to get it onto the CRM record. Before we start, you may want to clean up your code so it’s a bit easier to read. In this case, we changed the counter variable to be numberOfOpenTasks so that it’s clear exactly what we have counted. Use forward slashes (//) to comment out the info statements that are no longer needed. Now we have our three main variables we want to get onto the CRM record, newFirstNameProper, newLastNameProper, and numberOfOpenTasks.

Coding Pro Tip: Use clear, specific names for your variables, this will make your code easier to read later on.

Now, let’s get these variables back onto the lead record. Take a look at the JSON viewer to see what the API name is for each variable that you want to send to the lead record. Most of the time, the API name will have underscores between the words instead of spaces. So, with the variables we are using, newFirstNameProper and newLastNameProper will match up with the API names FIrst_Name and Last_Name, respectively. We will need to create a field for our numberOfOpenTasks variable in the CRM settings under Modules & Fields. Then the API name will show up in the Developer Space API settings page.

automate your business ad
Coding Pro Tip: Never change the API name after you have created functions with that variable. If you change the API name you will break the function!

Move all of the variables and API name lines into one line so that they are grouped together. Let’s make the update! Give the grouped line a variable name of updateInformation. Next, we will start a new line to create the update, starting with zoho.crm.updaterecord followed by the updateInformation. Run the update and check the lead to make sure everything got onto the CRM record correctly!

Map Functions

So far this process works well for updating a few fields in CRM. However, it can get rather clunky if you need to update 20 or more fields within a record. Deluge has Map Functions that build JSON data maps to help make this process a lot cleaner. Add in a line that says updateInformation = map(). The open-close parentheses let the function know that it is open to receive key-value pairs. Tell the map what variables you want within by using the put function. This makes the function much easier to read!

Using Dynamic Arguments

Now that the function is running, you’ll notice that it is only running on that one record whose lead Id is entered at the top. To get this to run on additional records you’ll need to Edit Arguments. Add the lead Id as the parameter with the matching data type. When you hit Save & Execute, it will now ask you for what specific lead Id you are looking to run this function for.

You can also attach the function to a workflow rule so that this function will run automatically! Just make sure to configure the function so that the lead Id is associated with the correct merge field!

Additional Resources

Well, we’ve done it all, reading data, editing data, and writing data with deluge! Want to learn more about Deluge? Check out our other resources which include videos, articles, and guides by clicking here to visit the Deluge resource page

Billy Bates

Senior Web Developer

Billy is a Wordpress Developer with an eye for design. His knowledge will help our company website and client sites meet their goals. Billy and his young family have just moved to Ashland Oregon, and are looking forward to exploring the area’s amazing beer, wine, and food. He also has a passion for synthesizers and drum machines.

Lucas Sant'Anna


With a background in Operations Research and Data Analysis, Lucas is a Brazilian programmer that likes to get stuff done quickly and reliably. In previous jobs, he implemented industrial job scheduling, fleet management and detailed long-haul route optimization – among other data-driven processes – to reach objectives of increased profit and reduced wasted resources. His goal is to make Zoho fully automated and with more meaningful data for spot-on decisions.