Good afternoon,
I have a custom function (created with the help of Zoho support) which takes information from the contact record in order to create a deal.
When we select a blueprint button in the contact record, to send out an application form, it pops up to validate the following fields: -
Once validated, the blueprint will send out an application form to the contact and also run the following code in order to create an opportunity with information from the above fields, but it is not working properly.
- resp = zoho.crm.getRecordById("Contacts",conid);
- prop = resp.get("Property_Applied_For").get("id");
- pre = resp.get("Property_Applied_For").get("name");
- relUnits = zoho.crm.getRelatedRecords("Rental_Units","Properties",prop);
- unit = "";
- if(relUnits.size() > 0 && relUnits != null)
- {
- pre = relUnits.get(0).get("Name");
- unit = relUnits.get(0).get("id");
- }
- info "prefix : " + pre;
- name = resp.get("Full_Name");
- dealName = pre + " - " + name;
- mp = Map();
- mp.put("Deal_Name",dealName);
- mp.put("Opportunity_Type","Tenancy");
- mp.put("Pipeline","Tenant");
- mp.put("Stage","Awaiting Application");
- mp.put("Current_or_Recent_Tenant",true);
- mp.put("Contact_Name",conid);
- if(unit != "")
- {
- mp.put("Unit",unit);
- }
- info "unit:" + unit;
- info "mp:" + mp;
- upd = zoho.crm.createRecord("Deals",mp);
- info upd;
As an example, I have validated the following in the contact record today: -
The output was a deal created with the name "Room 1 (Gold Crest) - <tenant name>" when it should have been "Room 6 (Madison) - <tenant name>" as the validated fields above suggest.
The "property" lookup field in the deal was blank. This should have been "1 Kirkby Road"
The "unit" field in the deal was "Room 1 (Gold Crest)" and as above, this should have been "Room 6 (Madison)".
Is anyone able to see why this might be happening?
Thanks in advance
Rich