Welcome to Portal

?Unknown\pull-down

Welcome to Zoho Cares

Bienvenido a Soporte de Zoho

Search our knowledge base, ask the community or submit a request.

Hi,

I am collecting subform data into a Lead record and I need to create individual records for each row associated to the account when it is converted.

How can I do this?

1 user has this question.
13 Replies
Reply
2 more

 no probs Jason. Feel free to come back to me with any questions if you get stuck with it. 

  • Zoho MVP
  • 27 days ago
  • Best answer

Hi
,

Zoho Flow doesn't currently have the ability to process loops with low code so you would still need to write a deluge function within Zoho Flow to loop through the subform records.

Because of this I'd suggest not using Zoho Flow and using a deluge function associated with a workflow to retrieve the subform data (Only 2 additional lines of code) and then loop through it to create your records based on the Subform Data.

Here is some sample code to get you started.
  1. dealMap = zoho.crm.getRecordById("Deals",recordId);
  2. subformList = dealMap.get("Subform_API_Name");
  3. //
  4. if(subformList.size() > 0)
  5. {
  6.       for each subformRow in subformList
  7.       {
  8.             createMap = Map();
  9.             //Populate Create Map with fields
  10.             createRecordResponse = zoho.crm.createRecord("Module_API_Name",createMap);
  11.             info createRecordResponse;
  12.       }
  13. }
Hope that helps.


 


Thanks Hugh, that's really helpful.

The best answer might be a mix of both, I personally prefer using Zoho Flow, to keep everything in the same place and as low code as possible. But, either way as Hugh said you will have to write some code, I find this easier in Zoho Flow as once you write a function you can save it and use it again with different variables in the future (This is just personal preference, everyone is different). If your okay writing deluge, you could extract the subform entries and do all the calculations in Zoho CRM through a custom function, in my opinion however this is harder to maintain and less accessible for normal/new people who have not learnt deluge. 

I appreciate the insight though and a hybrid approach might be a good start, you could have the custom function in Zoho CRM extract the subform payloads like in Hugh's post and then send each entry as an individual webhook payload to Zoho Flow where you can then use low code to finish the process.

In summary:

Hugh's suggestion = most efficient, most difficult (if you don't know deluge)
Max's suggestion = Low code, less difficult, not ideal for high volume, still requires code.
Hybrid approach = Less code + efficient, medium difficulty since the function is just for extracting the entries and sending them as webhook payloads. 

Discuss your idea/problem with me on Fiverr

  • 26 days ago

Thank you both
 and
  for your input.
I'll try a hybrid of your suggestions and see what works best.

Jason

 

No problem, I’m glad to help.

Let me know if you get stuck with anything. 

  • 21 days ago

Hey
 and
 

I have a workflow set up to trigger this function when a new Company record is created. 
The subform data is pushed into the Company subform when the Prospect is converted.
The function says it's executing successfully, but I'm getting the following error  for "Last Name. Any idea why?
The last name field on the Individual record has data in it.


  • Zoho MVP
  • 21 days ago

Hi
,

You are so close but you need to populate the createMap with data prior to creating the record and you need to extract the field values from the subformRow object relative to the subform fields using their API Names.

You can find them under Settings > Developer Hub > API & SDKs > Accounts > Right Down the bottom you will see the Subform API Field Names.
  1. dealMap = zoho.crm.getRecordById("Accounts",recordId);
  2. subformList = dealMap.get("Management_Team_Members");
  3. //
  4. if(subformList.size() > 0)
  5. {
  6.       for each subformRow in subformList
  7.       {
  8.             createMap = Map();
  9.             //Populate Create Map with fields
  10.             createMap.put("First_Name", subformRow.get("API_Name_Subform_Field"));
  11.             createMap.put("Last_Name", subformRow.get("API_Name_Subform_Field"));
  12.             createMap.put("Management_Title", subformRow.get("API_Name_Subform_Field"));
  13.             createMap.put("Previous_Experience", subformRow.get("API_Name_Subform_Field"));
  14.             createRecordResponse = zoho.crm.createRecord("Contacts",createMap);
  15.             info createRecordResponse;
  16.       }
  17. }
Hope that helps.


  • 19 days ago

Thanks
 .
Unfortunately, I'm still getting the same error. 
I think that the last name from the Accounts subform is not pushing over to the last name in the Contact record.
I created the API's with the same name.


  • Zoho MVP
  • 19 days ago

Hi
 

That is because you need to put your createRecordResponse AFTER your createMap. e.g. move line 12 to after line 16. 
The error is because your createMap is empty at the time the system is trying to create the contact.
  1. dealMap = zoho.crm.getRecordById("Accounts",recordId);
  2. subformList = dealMap.get("Management_Team_Members");
  3. //
  4. if(subformList.size() > 0)
  5. {
  6.       for each subformRow in subformList
  7.       {
  8.             createMap = Map();
  9.             //Populate Create Map with fields
  10.             createMap.put("First_Name", subformRow.get("First_Name"));
  11.             createMap.put("Last_Name", subformRow.get("Last_Name"));
  12.             createMap.put("Management_Title", subformRow.get("Management_Title"));
  13.             createMap.put("Previous_Experience", subformRow.get("Previous_Experience"));
  14.             createRecordResponse = zoho.crm.createRecord("Contacts",createMap);
  15.             info createRecordResponse;
  16.       }
  17. }
I also see you are populating the Management Title field by both Management Title and Previous Experience Fields from the subform. 

Let me know how you go.

Regards,


  • 15 days ago

It worked! Thanks
 .

The last piece I needed wass to attach the individuals to the company record, which I got to work as well.

void automation.Subformsrowstoindividuals(Int recordId)
{
dealMap = zoho.crm.getRecordById("Accounts",recordId);
subformList = dealMap.get("Management_Team_Experienc");
//
if(subformList.size() > 0)
{
for each  subformRow in subformList
{
createMap = Map();
//Populate Create Map with fields
createMap.put("First_Name",subformRow.get("First_Name"));
createMap.put("Last_Name",subformRow.get("Last_Name"));
createMap.put("Management_Title",subformRow.get("Management_Title"));
createMap.put("Previous_Experience",subformRow.get("Previous_Experience"));
//createRecordResponse = zoho.crm.createRecord("Contacts",createMap);

// Add the Account reference to link the Contact to the Account
            createMap.put("Account_Name", dealMap.get("id")); // Link to the Account using the Account ID
            
            // Create the new Contact record
            createRecordResponse = zoho.crm.createRecord("Contacts", createMap);
            info createRecordResponse;
        }
    }
}

Thanks much.

Jason

  • Zoho MVP
  • 15 days ago

Happy to help, glad you got it working!

Reply to JKylesA
/* */
  • 12
  • Insert
  • Plain text
Add Comment
(Up to 20 MB )