Deluge function not writing lead IDs or updating lead
Hi all.
I'm working on my first Deluge function. The intent is that it gets fired as part of a workflow whenever a certain field is updated for a lead record. The function needs to write a record to a custom module, and also update the lead record based on certain criteria.
Here is the code.
- Void Create_Score_Status_Audit (int LeadID, int PersonScore, string ScoreStatus )
- {
- NewScoreStatus=input.ScoreStatus;
- OldScoreStatus=input.ScoreStatus;
- CurrentPersonScore=input.PersonScore;
- CurrentLeadID=input.LeadID.toString();
- if((CurrentPersonScore > 0) && (CurrentPersonScore <= 30))
- {
- NewScoreStatus="Cold Lead";
- }
- else if((CurrentPersonScore > 30) && (CurrentPersonScore <= 60))
- {
- NewScoreStatus="Warm Lead";
- }
- else if((CurrentPersonScore > 60) && (CurrentPersonScore <= 90))
- {
- NewScoreStatus="Very Warm Lead";
- }
- else if(CurrentPersonScore > 90)
- {
- NewScoreStatus="Hot Lead";
- }
- if(NewScoreStatus != OldScoreStatus)
- {
- ScoreStatusAuditMap=map();
- ScoreStatusAuditMap.put("LeadID",CurrentLeadID);
- ScoreStatusAuditMap.put("New Status",NewScoreStatus);
- ScoreStatusAuditMap.put("Old Status",OldScoreStatus);
- ScoreStatusAuditMap.put("Date of Change",zoho.currenttime);
- updateResp = zoho.crm.create("CustomModule2",ScoreStatusAuditMap);
- LeadUpdateMap=map();
- LeadUpdateMap.put("Score Status",NewScoreStatus);
- updateResp = zoho.crm.updateRecord("Leads",CurrentLeadID,LeadUpdateMap);
- }
- }
When the workflow triggers:
- The audit record gets written (with correct score status values for old and new), but with no lead (I have a lead lookup in the module)
- The lead doesn't get updated with the new Score Status value .
What am I missing here??
Cheers
Jo