CRM : Function to add user name to text field
I have a lookup field in a module that is linked to the CRM users so we can assign a Project Lead to the customer. Sadly Zoho Marketing Automation doesn't sync Lookup fields so I need to extract information from the lookup to text fields:
Lookup field : Project_Lead
Text Field : Project_Lead_Name
Text Field : Project_Lead_Email
I want this to happen when the Project Lead is chosen via the dropdown and know this can be done via workflow with a custom function - I just can't find how to correctly write the deluge to pull the associated details and update the other fields.
I've used a bit of GPT to get me started, but it can't get the nuance right and I don't have the experience.
- void automation.Customer_Update_ProjectLeadName()
- {
- userId = input.Project_Lead;
- if(userId != null)
- {
- userDetails = zoho.crm.getRecordById("users", userId.toLong());
- if(userDetails.containKey("full_name"))
- {
- fullName = userDetails.get("full_name");
- updateMap = map();
- updateMap.put("Project_Lead_Name", fullName);
- zoho.crm.updateRecord(input.module, input.id.toLong(), updateMap);
- }
- }
- }