I am trying to copy notes from a custom module onto a lead on a button press. I have managed to copy the note title & body but attachments are much different (as they are a related list?). I have wrote the below but I am getting error 400: Bad Request. Any ideas?
RelatedNotes = zoho.crm.getRelatedRecords("Notes","Prospects",ProspectId.tolong());
info "Related List NOTES: " + RelatedNotes;
RelatedAttachment = zoho.crm.getRelatedRecords("Attachments","Prospects",ProspectId.tolong());
noteowner = RelatedNotes.getjson("Owner").getjson("id");
for each note in RelatedNotes
{
notesmap = Map();
notesmap.put("Parent_Id",Leadcreate.get("id"));
notesmap.put("Note_Content",note.get("Note_Content"));
notesmap.put("Note_Title",ifnull(note.get("Note_Title"),""));
notesmap.put("Owner",noteowner);
notesmap.put("se_module","Leads");
notescreate = zoho.crm.createRecord("Notes",notesmap);
}
NoteID = RelatedNotes.getJSON("id");
//
//TEST
attachid = List();
for each Attachment in RelatedNotes
{
attachementId = Attachment.get("id");
attachid.add(attachementId);
}
for each item in attachid
{
downloadFile = invokeurl
[
type :GET
headers:header_data
detailed:TRUE
connection:"zhprospectscopier"
];
info "AttachmentID: " + item;
info "Note ID: " + NoteID;
resp = zoho.crm.attachFile("Leads",LeadID,downloadFile);
}
info "RESP: " + downloadFile;