Businesses are always looking for ways to refine their strategies, and one effective method is to analyze lost deals. Understanding why specific deals fell through can be a game-changer for future success. Take consulting firms, for instance—they carefully track lost proposals to identify gaps in their approach, enabling them to tailor their services to meet client needs better. Real estate companies do this as well, analyzing missed deals to uncover market trends and better understand what clients truly desire. Marketing agencies also evaluate their unsuccessful campaigns to determine what went wrong.
One effective approach to managing lost deals is to create a dedicated task within the project management tool. This enables teams to share insights about lost deals, improving their chances of success in future transactions. What if every lost deal in your CRM automatically created a project and a task within your Zoho Projects portal? Our low-code tools allow you to do just that.
Using functions, you can automatically create tasks in Zoho Projects for each closed-lost deal in your CRM. You just need to create a custom function and connect it to a workflow rule for the Deals module. Continue reading to learn how to accomplish this task in under an hour.
Permissions and availability
- Users with the Manage Extensibility permission can create connections and write custom functions.
- Users with the Manage Automation permission can create and update workflow rules.
- Users with the Manage Sandbox permission can manage the sandbox.
Requirements
- Create a Zoho OAuth connection with the required scopes for your Zoho CRM account, as detailed in the "Create Connection" section below. Learn more
- Create a workflow rule for the Deals module that will trigger a custom function whenever the deal's stage is set to Closed Lost. Learn more
- Write a custom Deluge function that creates a project and a task underneath it in Zoho Projects for your team members to follow up. Learn more
- Test the workflow rule in a sandbox before deploying it in your production environment. Learn more
Create a connection
The first step is to create an OAuth connection in your Zoho CRM account.
- Navigate to Setup > Developer Space > Connections.
- Click Create Connection.
- Select Zoho OAuth under Default Services.
- Specify a Connection Name.
You must enter this name in the code snippet below. - Select the following Scopes to request access.
- ZohoCRM.modules.ALL
- ZohoCRM.settings.ALL
- ZohoProjects.projects.ALL
- ZohoProjects.tasks.ALL
- ZohoProjects.portals.ALL
- Click Create and Connect.
- Click Connect, then click Accept to confirm authorization of access for the scopes requested by the client.
Create a workflow rule
The next step is to create a workflow rule linked to a custom function.
- Navigate to Setup > Workflow Rules > +Create Rule.
- Select the Module as Deals from the drop-down list.
- Provide a name for the rule. For example: "Create task for lost deals".
- Add a description, if required, then click Next.
- In the Execute this workflow rule based on section, do the following:
- Choose Record Action, then select Edit from the drop-down.
- Select Specific field(s) get modified and specify "When <Stage> is modified to <the value> <Closed Lost>".
Note: You can specify any other appropriate stage as needed. - Click Next.
- In the Which deals would you like to apply the rule to? section, select All Deals and click Next.
- Under Instant Actions, select Function and Write your own.
- Provide a name for the function, as well as a description, if necessary.
- On the Deluge Script Editor, do the following:
- Copy and paste the code given below.
- Click Edit Arguments.
- Choose Deals - Deal Id and name it dealId.
- Click the + icon to add more arguments.
- Choose Deals - Deal Name, name it dealName, then click Save.
- Click Save & Execute script.
- Click Save on the workflow rule page.
The code
portalResponse= zoho.projects.getPortals("connectionname");
info "portalResponse : " + portalResponse;
portalID = portalResponse.get("portals").get(0).get("id");
info "portalID : " + portalID;
createMap = Map();
createMap.put("name",dealName);
createMap.put("start_date",zoho.currentdate.toDate().toString("MM-dd-yyyy"));
info "createMap : " + createMap;
response = zoho.projects.createProject(portalID,createMap,"connectionname");
info "Created Response:" + response;
projectid = response.get("projects");
for each rec in projectid
{
projectID = rec.get("id");
projname = rec.get("name");
}
mp = Map();
mp.put("name",projname);
contdet = Map();
contdet.put("id",dealId.toString());
mp.put("Deals",contdet.tolist());
datalist = List();
datalist.add(mp);
datamp = Map();
datamp.put("data",datalist);
info "datamp : " + datamp;
resp = invokeurl
[
url :"https://www.zohoapis.com/crm/v2/Deals/" + dealId + "/Zoho_Projects/" + projectID
type :POST
parameters:datamp.toString()
connection:"connectionname"
];
info "resp : " + resp;
currentTimeInTimezone = zoho.currenttime.toString("MM-dd-YYYY","Asia/Calcutta");
createTaskParamMap = Map();
createTaskParamMap.put("name","Lost Deal Analysis");
createTaskParamMap.put("start_date",currentTimeInTimezone.toText());
createTaskParamMap.put("end_date",currentTimeInTimezone.addDay(2).toText("MM-dd-YYYY","Asia/Calcutta"));
info "createTaskParamMap : " + createTaskParamMap;
createTaskResponse = zoho.projects.create(portalID,projectID,"Tasks",createTaskParamMap,"connectionname");
info "Create Task Response: " + createTaskResponse;
Notes
- Replace "connectionname" with the name of the connection you specified while creating the connection (see the "Create a connection" section above).
- Replace "Asia/Calcutta" with your time zone to ensure accurate time representation.
- Customize the task name (e.g., Lost Deal Analysis) created for the lost deal as needed.
Test the solution
- Click the Deals tab.
- Open the deal record that you wish to mark as closed-lost.
If necessary, create a new deal for a contact. - Update the deal's stage to the one mentioned in the workflow rule. For example, Closed Lost.
The workflow rule will be triggered. - Check whether a new project has been created under the deal's name, along with a task in the Zoho Projects account.
Tip
- Configure and test the function in a sandbox to ensure that further development doesn't disrupt your production environment.
Did you find this useful? Try it out and let us know how it works. Share this with your team if they'd benefit from it! If you have questions, please don't hesitate to contact us.
More info
- ModuleDeals
- Trigger PointWorkflow Rule
- EditionEnterprise and above
- ComplexityHigh
- Implementation Time60 minutes

Looking for a custom solution?
Contact us, we will help enhance your productivity at lightning speed.
SUBMIT REQUEST