In this article, we’ll show you how to keep two modules in sync. Consider the following Task:
We want to automatically synchronize the information in this task back to the lead. For example, let’s say we wanted to synchronize this status back into the description field in the lead.
How do we do this?
Firstly, we’ll make a workflow. Click Setup in the top right of your CRM, then go to AUTOMATION>Workflow Rules.
Next, click “+Create Rule” on the right, which will lead you to the following screen:
As you can see, we’ve made the Module based on Tasks. Now, we’ll click Next. This will take you to the WHEN part of the workflow. We”re going to do it based on a field action like so:
After that, we’ll make it execute for all records:
Under “Instant Actions” click Function:
You’ll get a screen with a button that says Create New Function. Click that, and then click “Write your own” on the following screen:
We’ll name ours appropriately and then click “Edit Arguments”.
Set it for the Task id, and click save. From there, we’ll add some code to get the task record, lead ID, and school ID. We’ll also make an Update Map. This is what your final product should look like:
Click “Save & Execute Script” and we’ll test it out.
Copy the ID from the URL of your task, and paste it in before clicking Execute:
Here, you can see we’ve got the task data:
Back in the Console, you can see it’s got the What ID.
The What ID is the ID of the module that is connected to that task, which in this case is the Lead ID.
You can see in the What ID that it’s a map (or a JSON object). This is why our function had to include .get(“What_Id”) & .getJSON(“id”). Somewhat confusingly, “What_Id” has more than just the ID: it also has the name of the lead. That’s why we need to do getJSON(“id”) afterwards.
If we hop into our Lead, we can see it has done what we want it to do:
Hopefully, you find this process quite simple. As a recap, you
- Get the first module.
- Find the ID of the module that it’s linked to.
- Do an update.
That should fulfill your duties.