Hi!
I'm frustrated enough to finally write here :)
Brief explanation what I need to accomplish, because I want to save sales guys time when they create new lead.
The story:
When creating a new Lead, users want to select appropriate Contact from list and see the magic happen. The magic here they expect is that some Contact fields (phone, mobile, email, title, salutation, first name, last name and company name) get filled automagically after selecting proper Contact and they wouldn't have to type in those fields again, since the fields are already filled in the Contacts. Simple? That's what I thought also.
Now what I've done is:
1) I have created a lookup (on Contacts) field on the Lead module (see snip1).
2) I have created a Custom Function to retrieve Contact Details and update them to corresponding Lead Module fields. The code goes:
- void CopyContactsToLeads (int leadId, int contactId )
- leadIdStr=input.leadId.toString();
- contactDetails = zoho.crm.getRecordById("Contacts",input.contactId);
- mobile=ifnull(contactDetails.get("Mobile"),"");
- phone=ifnull(contactDetails.get("Phone"),"");
- email=ifnull(contactDetails.get("Email"),"");
- title=ifnull(contactDetails.get("Title"),"");
- companyname=ifnull(contactDetails.get(("Account Name")),"");
- salutation=ifnull(contactDetails.get("Salutation"),"");
- firstname=ifnull(contactDetails.get("First Name"),"");
- lastname=ifnull(contactDetails.get("Last Name"),"");
- //leadname=ifnull(contactDetails.get("Contact Name"),"");
- mp=map();
- mp.put("Mobile",mobile);
- mp.put("Phone",phone);
- mp.put("Email",email);
- mp.put("Title",title);
- mp.put("Company Name",companyname);
- mp.put("Salutation",salutation);
- mp.put("First Name",firstname);
- mp.put("Last Name",lastname);
- //mp.put("Lead Name",leadname);
- updateResp = zoho.crm.updateRecord("Leads",leadIdStr,mp);
For function edit screen, see "snip2".
Then I created a Workflow Rule, that gets (or should get) fired up every time I create or edit a Lead. Well, this is where the magic doesn't happen.
When I run unit test on this (deluge script editor -> Save & Execute) I get prompted for leadId and contactId, like expected. I input one of my test lead leadId and one of my test Contact contactId and yes, the magic happens. All this while in test mode.
However, I am probably missing something crucial here since when I try to create a new Lead and select Contact from lookup dialog and hit Save, nothing happens.
Can someone provide understandable walk-thru on this? There are many posts around this topic but they mostly just point to manuals "how to create custom functions" and "how to setup workflow rules". I think I'm missing the magic how to tie Custom Function to Workflow Rule so that they interact like I want.
Any help would be appreciated!
Regards
Sami Heinänen