function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
abhinav gangradeabhinav gangrade 

Apex code issue

Hi, Account and 'Private_Account_Information have look-up relationship. I want to copy PrivateAccount Information notes to Account notes. PrivateAccount Information have account_name field on it.

List<Notes_List> Noteslist  = new List<Notes_List>();
List<Note> memberList = new List<Note>([SELECT Body,CreatedById,CreatedDate,Id,IsDeleted,IsPrivate,LastModifiedById,LastModifiedDate,OwnerId,ParentId,SystemModstamp,Title FROM Note where parent.type='Private_Account_Information__c']); // getting all the notes
    for(Note source : memberList )
    {
  Note destination = new Note();
        destination.body = source.body;
        destination.ParentId ='001V000000HaOui'; // How to assign private account information.Account name here ??
  destination.IsDeleted = source.IsDeleted;
        destination.Title = source.title;
  destination.IsPrivate = source.IsPrivate;
  destination.OwnerId = source.OwnerId;
  Noteslist.add(destination);
  }
    }
     insert Noteslist; // inserting new notes
siddarth rajsiddarth raj
Rather Invidvidually Assigning you could clone the Note in the loop, I believe Parent Id of the Note Source is Private_account_Information__c, So use select id from Account where name in (select account_name from Private_account_Information__c where id :=source.parentId)

I am not pretty clear about your problem. This is what my suggestion from the understanding your problem.

Thanks
Sid