Mapping multiple values in a subform - each a different row.

Mapping multiple values in a subform - each a different row.

Hi there,

 

Along with zoho community forums help, I have created a workflow with a function that maps desired fields from my ‘Property enquiries’ module to my ‘Leads (buy / rent layout)’ module. The code is as follows:

 

//Code starts

propenrec = zoho.crm.getRecordById("Property_Enquiries",id);

emailrec1 = propenrec.get("Email");

propid = propenrec.get("PropID");

 

searchleadsrec = zoho.crm.searchRecords("Leads","(Email:equals:" + emailrec1 + ") and

(Layout.id:equals:xxxxxxxxxxxxx)");

 

info searchleadsrec.size();

if(searchleadsrec.size() > 0 && searchleadsrec != null)

{

leadid = searchleadsrec.get(0).get("id");

li = list();

m = Map();

 

defined 'propid'

m.put("PropID_String",propid);

li.add(m);

 

mp = Map();

mp.put("Property_Interest",li);

mp.put("Layout","xxxxxxxxxxx");

info "Map Value :" + mp;

info "Lead id :" + leadid;

update = zoho.crm.updateRecord("Leads",leadid,mp);

info update;

}

//Code ends

 

So basically the code above gets a record by id in the Property enquiries module (the first mentioned module), extracts the email & property id values - then searches for the email value in the second mentioned module - the buy / rent layout in leads module - and if that email exists in the specified leads module, we copy the value of the property id from the property enquiries module and paste it in the Property ID field within a subform in the specified layout in our leads module.

 

Some records in the property enquiries module could have the same email entries. And that’s absolutely how the system is supposed to work. However:

 

A problem arises however in terms of when multiple entries from the same email need to be mapped from one module to another using the function stated above. In that case, the way the function works now, if a record is created in the property enquiries module, then another record (2nd time) is created using the same email, when the function above is executed, the Property ID in the Property Interest subform mapped during the first entry is going to be overwritten by the second entry / submission.

 

Because this is the case, it does not allow for multiple data entries to be mapped within a subform from one module to another. In order to fix that we’ll need to work around it using sort of this condition:

 

If a property ID record entry already exists (was already mapped) in the subform, then create a new row inside the subform & add the next Property ID in the next row - below the last entry, so it does not overwrite the previous entry.

 

This way, we can map multiple records without any problem !

 

I would really really really appreciate some help in regards to this - Thank you so much.