My org has a 3rd party app where Users can submit Leads through an app on their iPad, one issue though is that the app inserts one field as a Note attached to the Lead, rather than as text filled into a field. Currently, someone has to go into each note and copy the body of the Note into the Lead field for it to be useful. I'm looking to automate this by writing a Trigger to copy this info when the Note is inserted to the 'Notes' field on the Lead, but I've had a hard time finding documentation on Notes on the SFDC website.

  • Hi Zack, welcome to SFSE! Please take a moment to visit the help center, scroll through the tour, and read How to Ask. This post doesn't contain a question. What have you tried? Where are you stuck? Please edit your post to ask something concrete or your post is unlikely to bring you much help.
    – Adrian Larson
    Commented Jul 28, 2017 at 3:27

1 Answer 1


This is a (fairly) trivial trigger to write. Here's a basic (non-error-proofed) version you could start with:

trigger NoteCopy on Note (after insert, after update) {
    // Notes attached to leads
    Note[] leadNotes = new Note[0];
    // Just notes for leads...
    for(Note record: Trigger.new) {
        if(record.ParentId != null && record.ParentId.getSObjectType() == Lead.SObjectType) {
    // No notes to process? We're done.
    if(leadNotes.isEmpty()) {
    // Update Lead records with new notes.
    Map<Id, Lead> records = new Map<Id, Lead>();
    for(Note record: leadNotes) {
        records.put(record.ParentId, new Lead(Id=record.ParentId, Note__c=record.Body));
    update records.values();

This basic version doesn't worry about record locks, overwriting existing note values, and other validation errors. However, in the general case, this should work for a relatively standard org.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .