Automatically create a project when deal is won (Zoho Projects and CRM)

07.05.21 03:51 PM By Andy

How it works

In this tutorial we are going to set up a workflow and a function that will create a project in Zoho Project, after a deal was modified in Zoho CRM. When a user makes specific changes in Zoho CRM, like updating the deal stage, this will trigger a workflow that will call a function, and this function will create the project, as well as transferring information from the deal.

Pre-requisites

Optional

This automation will NOT work if the account field on the Deal is empty. You can manually assign an Account, before wining the Deal, or you can create a workflow to do it. If you choose to create a workflow, here are the steps: https://www.blungo.com/blogs/post/workflow-assign-account-to-a-deal-automatically-zoho-crm

Creating the automation

Part 1: Adding a new connection

  1. In CRM, go to developer space and the to connections
  2. Click on Add new connection, and select ZohoOAuth
  3. Connection name: relateproject
  4. Connection Link name: relateproject
  5. Scope: choose these two variables: ZohoCRM.modules.ALL, ZohoProjects.projects.ALL, and ZohoProjects.projects.CREATE
  6. Click on "create and connect", and when a new window pops up, click on "accept"

Part 2: Adding a new function

  1. In the CRM, go to developers and then functions, and add a new function
  2. Name it "Create Project" and select automation as the category
  3. Copy the function listed below and paste in the function window
  4. Click on "edit arguments", and map the the arguments as shown in the image below the function
    • You need to map: ProjName, Description, TemplateID, PortalName as string and id as int
createMap = Map();
createMap.put("name",ProjName);
createMap.put("description",Description);
createMap.put("template_id",TemplateID);
//custom fields
//end of custom fields
response = zoho.projects.createProject(PortalName,createMap,"relateproject");
info response;
mp = Map();
mp.put("name",ProjName);
datalist = List();
datalist.add(mp);
datamp = Map();
datamp.put("data",datalist);
resp2 = invokeurl
[
url :"https://www.zohoapis.com/crm/v2/Deals/" + id + "/Zoho_Projects/" + response.getJSON("projects").getJSON("id")
type :POST
parameters:datamp.toString()
connection:"relateproject"
];
info resp2;

Part 3: Testing the function

  1. Click on "save and execute"
  2. In the new dialog, add your parameters:
    1. ProjName: Any name you want for the project
    2. Description: Any description
    3. TemplateID: Open the Zoho Projects template and copy the ID from the URL (ie: https://projects.zoho.com/portal/blungo#todomilestones/1600615000000748888/)
    4. PortalName: Open Zoho Projects and find it in the URL (ie: https://projects.zoho.com/portal/blungo#todomilestones/1600615000000748888/)
    5. id: Open a Deal in CRM and copy the Deal ID from the URL
  3. Click on save
If everything went well, you will get a long dialog box on the right, and at the end it will say that the function was successfully executed. If you get any errors, even if the function was successfully executed, you must have missed a step. Please remember that the Deal you are using to test this out has to have an Account related.

Part 4: Adding custom fields

To find custom fields API names from Zoho Projects, please follow this tutorial: LINK

You can reuse the connection you already created earlier on, or you can create a new connection.

A) Once you have the custom field API names:

  1. Right after "//custom fields", paste the following function:
    • createMap.put("ZOHO_PROJECT_FIELD_API",CRM_FIELD_API);
  2. Replace "ZOHO_PROJECT_FIELD_API" with the Zoho Project Field API name of the field you want to map
  3. In the CRM setup, go to "developer space" and the to "APIs"
    1. Click on "APIs names", and then click on Deals
    2. Find the field that you want to map, and copy the API name
  4. Go back to the function, and replace "CRM_FIELD_API" with the API name you just found
  5. Repeat the same steps for as many fields as you want to map
Note: to map a date field, you have to use the following function:
  • createMap.put("ZOHO_PROJECT_FIELD_API",CRM_FIELD_API.toString("MM-dd-yyyy"));

B) Map the arguments

  1. Click on "edit arguments"
  2. For each field you want to map, add one argument line
  3. Copy the "CRM API names" and paste them on the lines you added
    1. ie: createMap.put("UDF_CHAR1",Zoho_Drive_Folder);
  4. Select "string" as type, for all of them
  5. Click on "save"


Finally, save the function by clicking on "Save" on the top right corner.

Part 5: Creating the workflow

  1. Go to the workflows section and create a new one
  2. Name it and relate it to the deals module
  3. When: stage is modified
  4. Condition: stage is Signed (select any stage you want to trigger this workflow)
  5. Instant Action: Function
  6. Click on "functions" and select the function "create project"
  7. Now click on "configure", and map all the fields (press # for merge field)
    1. PortalName: find it in the ZohoProjects URL (ie: https://projects.zoho.com/portal/blungo#todomilestones/1600615000000748888/)
    2. TemplateID: find it in the template URL (ie: https://projects.zoho.com/portal/blungo#todomilestones/160061500000008888/)
    3. The rest of the fields are merge fields from the CRM, including id, which is the Deal ID
  8. Click on "save and associate"
  9. Finally click on Save

Now refresh the deal you want to test this automation on and move it to the signed stage. The new project should be created automatically in Zoho Projects, and all the fields from the CRM should be copied to the fields in Projects. Also the project should be linked to the CRM in the projects section.