Brief explanation what I need to accomplish, because I want to save sales guys time when they create new lead.
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:
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.
I'll test your tips and let you know how it goes, your observations make sense :)
I got few errors but I wasn't able to debug the error codes since the error log report showed only x characters when viewing the report lines. Didn't find a way to export the errors to file and investigate further...
Then the philosophy side of this (your side note):
from your perspective our way of using modules might seem unorthodox. I've noted that Zoho CRM has strong philosophy behind how things should be done. However, companies and processes are unique and therefore I find it weird that there are some limitations how flexible (on un-flexible) the system is.
How we use Zoho CRM in our sales and customer management: we have thousands of companies and contacts in our setup. Some of them are customers, some of them are prospects, some of them are suspects, some of them are competitors, some of them are just lying there waiting for to be sucked into lead & sales process. This is what we call our "bucket of gold". We have carefully selected these companies and contacts to form a base for our business growth.
On top of this bucket we have lead process, opportunity (potential in your slang) process, customer life cycle process and all the reporting. Not to mention all the various activities related to aforementioned.
So in this case: we want to create a lead from existing account and contact. We don't create leads from scratch. Account and Contact have to exist before lead can be generated. This is our business rule. And when lead progresses, it gets turned into Opportunity (Potential) and finally into Closed Won in best case.
I see your point of starting from Lead. But our process requires that Accounts and Contacts are there. That's why. And also, we don't either use Quotes, they are handled in different process that requires structured document management. We don't store any sales related documentation in Zoho CRM.
I hope this clarifies our background :)
I will give your suggestions a shot later today and see what happens. And we shouldn't be getting duplicate contacts, since the Zoho CRM conversion process asks whether user wants to create a new contact :)
Have a nice day, I hope we get this solved. I'm quite sure that I'm "not the only duck in the pond" that is facing this module-to-module autofill challenge.
Obviously there was an issue with Leads lookup field (Contact lookup) I was using to map contactId in my Custom Function and related Workflow Rule. I had several related lists linked to Contacts. But I'm not sure though. Anyway now I'm not getting any Custom Function failures while creating/editing Lead.
So here's what I did in case someone else is in same situation:
* created lookup field (Contact) so user can select proper Contact in the dialog
Custom Function used, I made modifications regarding null values like Thomas suggested:
Then I made sure, that in my Custom Function edit window I made correct Argument Mappings. I had Contacts listed three times (probably due to duplicate related lists) in mapping drop-down (CRM values). When I used the correct Contact Id, the workflow rule started triggering correctly.
After this I adjusted the Workflow Rule to trigger whenever Lead is created or edited AND it is Created OR Modified By = Logged in user.
So, the system was working like it was coded :) Problem was mostly between keyboard and chair...
Feel free to drop a line if you bump into similar situation :)