Scenario: Updating the owner of the related cases when the potential owner is updated.
A potential in Zoho CRM can have several cases associated with it. If you wish to assign the potentials to a new user, you may also want to assign the associated cases to the new user.
Currently, when the owner of the potential is changed, ownership to the associated cases will not be changed.
You can achieve this by custom function and change the ownership for associated cases
Please follow these steps:
Deluge Script:
void workflowspace.Change_Owner(string potentialId)//Getting PotentialID
{
potresp = zoho.crm.getRecordById("Potentials",input.potentialId.toLong());//Getting Potential Detail by using API
potrespStr=potresp.toString();//Converting Potential response in to String
potMap=potrespStr.toMap();//Converting String to Map
smownerid=potMap.get("SMOWNERID");//Getting OwnerID from potential Map
owner=potMap.get("Potential Owner");//Getting OwnerID from potential Map
resp = zoho.crm.searchRecordsByPDC("Cases","potentialid",input.potentialId);//Getting Cases Related To That Potential for each rec in resp//
{
caseID=rec.get("CASEID");
caseupresp = zoho.crm.updateRecord("Cases",caseID,{ "SMOWNERID" : smownerid, "Case Owner" : owner });//Upating owner of Each Cases Associated with that potential
}
}
Note: This custom function can be used not just for the Potentials and the associated cases. However, you can modify the custom function for any other modules with parent-child relationship.
Please refer to the following link to know more about this feature:
https://www.zoho.com/crm/help/automation/custom-functions.html