Issue with Java SDK Notes

Issue with Java SDK Notes

Hi,

I'm facing an issue when trying to iterate through retrieved Notes. Facing Exception:

java.lang.ClassCastException: class com.zoho.crm.library.crud.ZCRMRecord cannot be cast to class com.zoho.crm.library.crud.ZCRMNote (com.zoho.crm.library.crud.ZCRMRecord and com.zoho.crm.library.crud.ZCRMNote are in unnamed module of loader 'app')

Line highlighted BLUEbelow is where the stack trace is saying the error is.
This is a list of <ZCRMNote> retreived from Zoho, so I don't understand why it is suggesting I'm trying to cast them to ZCRMRecord...
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();
}
}

}

}
Any help would be appreciated.

Thanks,
Conan


    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation
                                          • Topic Participants

                                          • Conan



                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now