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
Ramadhar MishraRamadhar Mishra 

Task Reminder Override

Hi All,

 

 Any one pls help me on it............How I could achive?

 

In New task page we have Reminder Section. I want reminder setting as per the following way......

1). If user selects "Reminder" check box then changes the Time----> Reminder should come at the changed Time.

2). If user don't select "Reminder", then Reminder should come Current Time 1 hr.

 

Thanks in Advanced

 

 

NBlasgenNBlasgen
I haven't done this specificly for Activities, but look at doing a Trigger BEFORE Insert on Activities.
Ramadhar MishraRamadhar Mishra

Thanks for given me idea .....

 

How to get Reminder DataTime field api name.

Ramadhar MishraRamadhar Mishra

Hi,

 

The Code I have highlighted with Blue color ,is giving exception. So pls suggest me what field I can use place of "ReminderDateTime". To fulfill the requirement.

 

Thanks,

Ramadhar Mishra

+91 9600127624

trigger SendTaskEmailAlert_Reminder on Task (after insert) {
    try
    {
        String profileName = [select id, name from Profile where id=:UserInfo.getProfileId()].Name;
    
       //check if the current profile is not a feed user
       if(profileName != 'Feed User Profile')
       {
            sendEmailNotification();
       }
    }
    catch(Exception Ex)
    {
        //We don't have any specified exception for the business logic
        
    }
    

    private void sendEmailNotification()
    {
        List<Task> taskList = new List<Task>();
        Map<Id,User> userMap;
        Set<Id> ownerIdSet = new Set<Id>();
        Set<Id> taskIdSet = new Set<Id>();
       // Datetime cDT = System.now();
       // String LongDate = ' ';
 
        for(Task tsk:Trigger.New)
        {
           if(tsk.IsReminderSet==false){    
              System.Debug('I am Here');            
              tsk.ReminderDateTime=System.now();                
            } 
            System.debug('Inside 1st loop');
            if(tsk.Send_Notification_Email__c == true)
            {
                taskList.add(tsk);
                ownerIdSet.add(tsk.OwnerId);
                taskIdSet.add(tsk.Id);
                //tsk.Send_Notification_Email__c = false;
                //tsk.Subject = tsk.Owner.Email;
            }        
        }
                        
        if(taskList.size() > 0)
        {                   
            System.debug('Inside 2nd loop');
            // query for the email ids
            userMap = new map<Id,User>([Select Id,Email,Name from User where Id in :ownerIdSet limit 1000]);

            List<Messaging.SingleEmailMessage> messages = new List<Messaging.SingleEmailMessage>();

            for(integer j=0;j<taskList.size();j++)
            {
                //taskList.get(j).Send_Notification_Email__c = false;
                System.debug('Inside 3rd loop');
                String[] toAddresses = new String[1]; 
                toAddresses.clear();    
                toAddresses.add(userMap.get(taskList.get(j).OwnerId).Email);
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                mail.setSubject(taskList.get(j).Subject);
                String objURL = taskList.get(j).Application_URL__c+taskList.get(j).Id;
                String SSOUrl = '<a href =https://clientmanagement.privatebank.citigroup.net/sfdc>';
                // The email text
            mail.setHtmlBody('A new action item has been assigned to you by '+UserInfo.getName()+'.<p>' +' '+SSOUrl+' Log into Salesforce.com  </a><p>'+' On Salesforce Home Page, Scroll down to Action Item Section &  Select the "Assigned To Me" Tab');
               // mail.setHtmlBody('A new action item has been assigned to you by '+UserInfo.getName()+'.For more details on this action item, Please follow the below steps.<p>' +' If you are already logged in to Salesforce, Please ignore the STEP 1<p>'+'STEP 1: Please click the URL and login using Single Sign On username and password  <p>'+'STEP 2: Please click the link below to locate the assigned action Item  ');
                //mail.setHtmlBody('A new action item has been assigned to you by '+UserInfo.getName()+'.For more details on this action item, click on the link below:<p>'+objURL+');
                mail.setToAddresses(toAddresses);
              //  mail.setHtmlBody('A new action item has been assigned to you.For more details on this action item, click on the link below:<p>'+'<a href='+objURL+'>'+objURL+'</a>');
                System.debug('Inside 4th loop : '+toAddresses);
                messages.add(mail);
            }            
            Messaging.sendEmail(messages);  
       }         
    }  
}