I have 2 modules. The parent module is Properties. The child module is Spaces.
Properties stores data for an entire building including the city given address (single line), legal description (single line) and city (single line). To create a record in Spaces a Property from Properties will need to be selected.
When I add a new entry into Spaces the Address is a lookup field that relates to the Properties module. I have the same titled and type of fields in the Spaces module as I do the Properties module. When the Address is selected from the lookup field in the Spaces module I want the Legal Description and City fields to auto populate from the Properties module information.
I found many help documents but I worked from this one as it had the best comments to help me figure out how I would have to change my code to fit my situation: https://help.zoho.com/portal/community/topic/make-a-lookup-field-auto-populate-other-fields
Based on this above help document here is my code that I believe should work but does not pull any data as I am hoping it too. Any suggestions on what I may be doing wrong or how I can get this to work?
________
voidgetParentAddressDetails(Int addressId)
// --- get the address record you're on
addresscoe = zoho.crm.getRecordById("Spaces",addressId);
// --- lookup the value in the "Address COE" field on your space, this is returned as an array with "name" and "id" values related to the address you've specified in the lookup field on the Space
addressLookup = addresscoe.get("Property");
// --- if conditional that checks your "Address COE" field on the space, if null, the function terminates, if not null, the below function is carried out
if(addressLookup != null)
{
// --- gets the "id" from the returned list from the "Address COE" field, this is critical because the addressLookup result returns both "name" and "id", you must get the "id" in order to lookup your Address record from the ?Spaces or Properties? module
addressId = addressLookup.get("id");
// --- get the Address record from the Properties module using addressId
property = zoho.crm.getRecordById("Properties",addressId);
// --- get the "City" field value from the related City record
city = ifnull(property.get("City"),"");
// --- get the "Legal Description" field value from the related Legal Description record
legal_description = ifnull(property.get("Legal_Description"),"");
// --- creates a Map() array in which we'll store "City" and "Legal Description" values from the Property record
propertyMap = Map();
// --- add the "Capital" value to the Map()
propertyMap.put("City",city);
// --- add the "Population" value to the Map()
propertyMap.put("Legal_Description",legal_description);
// --- update the currentlead record with the "City" and "Legal" values from its related Property record, which was stored in our propertyMap()
updateProperty = zoho.crm.updateRecord("Spaces",addressId,propertyMap);
}