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
Sai Karthik KVSSai Karthik KVS 

Process Builder/ Work flow help

Last note and notes should get auto populate if we fill one in either of them.
I had custom field LAST NOTE in my opportunity layout. And I had field New Note is under Notes and Attachments related list in the layout. When we enter the Last Note, I wanted to display the same in the New note? How does it possible? I mean without doing it twice (Copy and paste), I just wanted to auto populate it.  when I create Last Note, it should get auto populate the same in New NOTE and create record whenever I create Last note which means there should be all the information in Nee Notes related list whenever I create last note.
Can you please help me out.Thank you
Best Answer chosen by Sai Karthik KVS
HARSHIL U PARIKHHARSHIL U PARIKH
I think I am understanding your requirements. Its looks like you want to store all the past values of Last_Note__c field into the Notes 7& Attachment section correct!?

Here is a trigger that would do the job:
 
Trigger NewNotesCreation On Opportunity(After Insert, After Update){
    
    List<Note> notesFinalListToInsertForAfterInsertOpps = New List<Note>();
    List<Note> notesFinalListToInsertForAfterUpdateOpps = New List<Note>();
    
    If(Trigger.IsInsert)
    {
        For(Opportunity Opp : Trigger.New)
        {
            If(Opp.Last_Note__c != Null)
            {
                Note nt = New Note();
                nt.Title = Opp.Last_Note__c;
                nt.parentId = Opp.Id;
                notesFinalListToInsertForAfterInsertOpps.add(nt);
            }
        }
        try{
            If(!notesFinalListToInsertForAfterInsertOpps.IsEmpty()){
                insert notesFinalListToInsertForAfterInsertOpps;
            }
        }
        catch(Exception e){
            System.debug('Thrown Exception while inserting notesFinalListToInsertForAfterInsertOpps is:: ' + e.getMessage());
        }
    }
    
    If(Trigger.IsUpdate)
    {
        for(Opportunity Opp : Trigger.New)
        {
            
            If(Opp.Last_Note__c != null)
            {
                String oldvalueOfLastNote = Trigger.OldMap.get(Opp.Id).Last_Note__c;
                string newValueOfLastNote = Opp.Last_Note__c;
                
                Boolean lastNoteHasChanged = (oldvalueOfLastNote != newValueOfLastNote);
                
                If(lastNoteHasChanged){
                    Note nt = New Note();
                    nt.Title = newValueOfLastNote;
                    nt.parentId = Opp.Id;
                    notesFinalListToInsertForAfterUpdateOpps.add(nt);
                }
                
            }
            try{
                If(!notesFinalListToInsertForAfterUpdateOpps.IsEmpty()){
                    insert notesFinalListToInsertForAfterUpdateOpps;
                }
            }
            Catch(Exception e){
                System.debug('Thrown Exception while inserting notesFinalListToInsertForAfterUpdateOpps Is:: ' + e.getMessage());
            }
        }
    }
}
This is what the Trigger Does:

Let's say you create an opportunity with name of "Burlington Opp - 1" and provide value in field "Last_Value__c" as "Burlington Note - 1" and hit the save button, at this moment you should have new automatic note record created under "Notes & Attachment" section with note title as "Burlington Note - 1" 
Now, if you change "Last_value__c" on "Burlington Opp - 1" to "Burlington Note - 2" then you should have another automatic note record got created with title as "Burlington Note - 2" etc.. 

Sample Image For the behavior:

User-added image

Hope this helps!

All Answers

HARSHIL U PARIKHHARSHIL U PARIKH
I think this is possible using trigger but however, which note record should be updated?

Let's say you have an Opportuny named Opp-1 and it has value as "Sample Note" in Last_Note__c field. Now let's say you have 5 different notes records for this opportunity named "Opp - 1."
Which record out of 5 should be upadted with New_Note__c field as "Sample Note"?
Sai Karthik KVSSai Karthik KVS
Govind, 
Thank you for your response. Yeah when I update Last_Note__c field, I wanted to maintain the same in Notes and attachments section. So in Notes and attachment related list, I want all the Last_Note__c data to be added in the Notes related list section. In the screenshot, I've tried doing it through process builder, but the thing is when I update my last_note__c then all my Notes are chaning as per the last note. But I dont want that. I need new Notes when I edit/update my Last_Note__c. Pardon me if I'm wrong in framing question. That would be fine if I can get help with the trigger. 
Thank you and really appreciated. User-added imageUser-added image
 
HARSHIL U PARIKHHARSHIL U PARIKH
I think I am understanding your requirements. Its looks like you want to store all the past values of Last_Note__c field into the Notes 7& Attachment section correct!?

Here is a trigger that would do the job:
 
Trigger NewNotesCreation On Opportunity(After Insert, After Update){
    
    List<Note> notesFinalListToInsertForAfterInsertOpps = New List<Note>();
    List<Note> notesFinalListToInsertForAfterUpdateOpps = New List<Note>();
    
    If(Trigger.IsInsert)
    {
        For(Opportunity Opp : Trigger.New)
        {
            If(Opp.Last_Note__c != Null)
            {
                Note nt = New Note();
                nt.Title = Opp.Last_Note__c;
                nt.parentId = Opp.Id;
                notesFinalListToInsertForAfterInsertOpps.add(nt);
            }
        }
        try{
            If(!notesFinalListToInsertForAfterInsertOpps.IsEmpty()){
                insert notesFinalListToInsertForAfterInsertOpps;
            }
        }
        catch(Exception e){
            System.debug('Thrown Exception while inserting notesFinalListToInsertForAfterInsertOpps is:: ' + e.getMessage());
        }
    }
    
    If(Trigger.IsUpdate)
    {
        for(Opportunity Opp : Trigger.New)
        {
            
            If(Opp.Last_Note__c != null)
            {
                String oldvalueOfLastNote = Trigger.OldMap.get(Opp.Id).Last_Note__c;
                string newValueOfLastNote = Opp.Last_Note__c;
                
                Boolean lastNoteHasChanged = (oldvalueOfLastNote != newValueOfLastNote);
                
                If(lastNoteHasChanged){
                    Note nt = New Note();
                    nt.Title = newValueOfLastNote;
                    nt.parentId = Opp.Id;
                    notesFinalListToInsertForAfterUpdateOpps.add(nt);
                }
                
            }
            try{
                If(!notesFinalListToInsertForAfterUpdateOpps.IsEmpty()){
                    insert notesFinalListToInsertForAfterUpdateOpps;
                }
            }
            Catch(Exception e){
                System.debug('Thrown Exception while inserting notesFinalListToInsertForAfterUpdateOpps Is:: ' + e.getMessage());
            }
        }
    }
}
This is what the Trigger Does:

Let's say you create an opportunity with name of "Burlington Opp - 1" and provide value in field "Last_Value__c" as "Burlington Note - 1" and hit the save button, at this moment you should have new automatic note record created under "Notes & Attachment" section with note title as "Burlington Note - 1" 
Now, if you change "Last_value__c" on "Burlington Opp - 1" to "Burlington Note - 2" then you should have another automatic note record got created with title as "Burlington Note - 2" etc.. 

Sample Image For the behavior:

User-added image

Hope this helps!
This was selected as the best answer
Sai Karthik KVSSai Karthik KVS
Thank you so much Govind :-)
 
Sai Karthik KVSSai Karthik KVS
Govind, 
Any idea about this?
Lead Status:

If Lead Status is Active or Follow up, I wanted to follow up with lead in 10 days or older and it should automatically redirect to Campaign (Custom Campaigns) and show us the report of it and then we can follow up with lead through dialer. So below screenshot shows the dependant fields, and there we have Lead Status. So how will it redirect to the Campaign if Lead Status is follow up with 10 days or older? Pardon me if I did any wrong in framing the question. 
HARSHIL U PARIKHHARSHIL U PARIKH
Hello Sal,

Would it be possible for you create a new question for the question above since it will help our developer community users if they run into the similar question. I appreciate your effort!!