Deluge help: Cannot figure out why this isn't working with more than one attachment
I have an email parsing in Zoho CRM that drops into a custom module. It is also set to upload all of the email attachments when the parsing runs. This works fine. I have a workflow that runs when a new record is created in the custom module. It calls a deluge script that is supposed to loop through the record attachments and then move them over to the associated trip. It works when there is one attachment, but it’s not moving all of them when there is more than one.
I keep looking at the code and I can’t figure out why.
info trip_details;
for each tripinfo in trip_details
{
tripid = tripinfo.get("id");
info "Trip Id: " + tripid;
contactdata = tripinfo.get("Contact_Name");
if(!isEmpty(contactdata))
{
for each contact in contactdata
{
contactid = contactdata.get("id");
contactname = contactdata.get("name");
}
/*Get Any Attached files from parsed email and move them to trip*/
theDocuments = zoho.crm.getRelatedRecords("Attachments","Email_Parsings",parseid);
info "The Documents: " + theDocuments;
if(!isEmpty(theDocuments))
{
info "The Documents inside loop: " + theDocuments;
for each doc in theDocuments
{
docid = doc.get("id");
info "docid: " + docid;
attachmentDoc = invokeurl
[
url :"https://www.zohoapis.com/crm/v2/Email_Parsings/" + parseid + "/Attachments/" + docid
type :GET
connection:"crmcoql"
];
info attachmentDoc;
info "Doc id: " + docid;
response = zoho.crm.attachFile("Deals",tripid,attachmentDoc);
info response;
}
}
}
else
{
info "contact is empty";
}
}