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
Chinna SfdcChinna Sfdc 

Opty field value update in the Task Comments Field

Hi Team,

How to populate the opty field value in the Task object comments field.Let's say we have a field called  Description,whenerver we are entered in the description field same comments it should be populate in the Task comment field.

How to acheive this one.

Thanks in Advance
Uday Kumar 43Uday Kumar 43
Hello Chinna Sfdc,

You might achieve this with Triggers. Create trigger on Opportunity, When ever opty field is updated, get all tasks on Opportunity and update the value in Task comments. You can filter tasks related to Opportunity based on WhatId.

Hope this helps.

Please mark as best answer if this helps!
Chinna SfdcChinna Sfdc
Hi Uday,

Thanks for your suggestions.

We written a trigger on opportunity as working expected but i want to include Due date in this trigger Which means DueDate = CreatedBy + 7 days. How to acheive this one .Please find bit of trigger.

if(Trigger.isUpdate){
    Map<Id,Opportunity> oldOppMap = Trigger.oldmap;
     for (Opportunity Opp: Opps){
         //Check If description got changed
         if(Opp.Helps__c != oldOppMap.get(opp.Id).Helps__c ){
            Task t = new Task();
            t.WhatId = opp.Id;          
            t.Subject = 'Help' + ': '  + opp.Name; 
            t.Description = opp.Description__c;             
            taskList.add(t);
         }

Please help us that would be great.

Thanks in Advance


 
Rakesh51Rakesh51
Use the Declarative tool of Salesforce to complete your task.  In the Process Builder check if Description field is changed then update related task Description.

You can also use Flow with process builder to handle it. 
Uday Kumar 43Uday Kumar 43
Glad it worked for you! You can update due date as follows

t.ActivityDate = opp.CreatedDate.addDays(7); //If you want set due date after 7 days of opportunity creation date
OR
t.ActivityDate = DateTime.now().addDays(7); // to set 7 days after task creation date

Thanks,
Uday
Faizan Nusrat 12Faizan Nusrat 12
Using trigger we can do this