public static void syncNotes()throws ZCRMException{
/**
* get unique list of lead ids of all notes
* for each lead (id), get notes from zoho
* for each file note for that Lead
* check if it matches one of the existing zoho notes (content and title)
* if not, add it
*/
for (int row : Note.getRowsSet()){
long id = Maps.getRowIDMap().get(row);
System.out.println("Row: " + row);
System.out.println("ZID: " + id);
ZCRMRecord record = ZCRMRecord.getInstance("McD_Project_Leads",id);//module api name with record id
BulkAPIResponse response = record.getRelatedListRecords("Notes");
List<ZCRMNote> notes = (List<ZCRMNote>)response.getData();//relatedList name
for (Note fileNote : Note.getNotesList()){
boolean existsInZoho = false;
System.out.println("File Row: " + fileNote.getRow());
System.out.println("Row: " + row);
if (fileNote.getRow() == row){
for (ZCRMNote note : notes){
System.out.println(note.getContent());
System.out.println(note.getTitle());
if (fileNote.getContent().equals(note.getContent()) && fileNote.getTitle().equals(note.getTitle())){
existsInZoho = true;
System.out.println("Matches, skipping");
}
}
}
if (!existsInZoho){
System.out.println("No match, adding");
//add it record in zoho
ZCRMNote note = new ZCRMNote(record);
note.setContent(fileNote.getContent());
note.setTitle(fileNote.getTitle());
APIResponse noteResponse = record.addNote(note);
ZCRMNote createdNote = (ZCRMNote) noteResponse.getData();
String recStatus =response.getStatus();
}
}
}
}
Writer is a powerful online word processor, designed for collaborative work.