• Myron Fair
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies
I need some clarification regarding Object Setting and Field Settings under the profiles "Object Settings". User-added imageIf the Object settings is set to 'Read', but the Field Settings are set to 'Edit', will the user have edit rights to these fields? So essentially, by selecting the edit access, is this overriding or giving further access?
I'm assuming that they will have edit right due to the nature of permission sets 'granting' additional privileges instead of taking them away. Just a little confuses as to why a user with only Read access to an object should be able to edit a field, but if that's the case the option should be "Read Only". Thanks!
I have recently taken over as the admin and I am going through all of the currenty Apex Classes and have stumbled upon one that I can't seem to properly test for confirmation purposes. This particular class is suppose to be responsible for auto-expiring and terminating contracts based on the given criteria. When I create test records with the suspected criteria, the trigger seems to not happen, the records status' do not change. I don't know what I'm missing or if it's something in the code itself. The criteria for the test that I perform is below, and I typically set the record to expire or terminate the very next day. Please help me understand what this class is suppose to do!!!

Agreement Expiration
1.   All Record Types excluding ‘ Bulk Purchase Contract’, Bulk Sales Contract’, and ‘Bunker Sales Contract’.
2.  Agreement End Date: Today
3.  Auto Renew: False
4.  Evergreen: False
5.  Agreement Status: Does not equal to ‘Expired’ or ‘Terminated’.
*Once the Agreement End date occurs, the status of the record should update to Expired.

Agreement Termination
1.   All Record Types excluding ‘ Bulk Purchase Contract’, Bulk Sales Contract’, and ‘Bunker Sales Contract’.
2.   Agreement Status: Does not equal to ‘Expired’ or ‘Terminated’.
3.   Termination Date = Today
*Once the Termination Date occurs, the status of the record should update to Terminated.

Here is the Code.
 
global class AgreementNotifierScheduler implements Schedulable {
    global void execute(SchedulableContext ctx) {
        Map<Id, List<Apttus__APTS_Agreement__c>> expiredAgreementsMap = new Map<Id, List<Apttus__APTS_Agreement__c>>();
        Map<Id, List<Apttus__APTS_Agreement__c>> terminatedAgreementsMap = new Map<Id, List<Apttus__APTS_Agreement__c>>();
        Map<Id, List<Apttus__APTS_Agreement__c>> almostExpiredAgreementsMap = new Map<Id, List<Apttus__APTS_Agreement__c>>();
        Id recType1 = Schema.SObjectType.Apttus__APTS_Agreement__c.getRecordTypeInfosByName().get('Bulk Purchase Contract').getRecordTypeId();
        Id recType2 = Schema.SObjectType.Apttus__APTS_Agreement__c.getRecordTypeInfosByName().get('Bulk Sales Contract').getRecordTypeId();
        Id recType3 = Schema.SObjectType.Apttus__APTS_Agreement__c.getRecordTypeInfosByName().get('Bunker Sales Contract').getRecordTypeId();
        List<Messaging.SingleEmailMessage> emailsToBeSent = new List<Messaging.SingleEmailMessage>();
        List<Apttus__APTS_Agreement__c> agreementsToUpdate = new List<Apttus__APTS_Agreement__c>();
        List<Apttus__APTS_Agreement__c> allAgreements = [SELECT Id, 
                                                         OwnerId, 
                                                         Name,
                                                         Apttus__FF_Agreement_Number__c,
                                                         Apttus__Contract_End_Date__c, 
                                                         Apttus__Auto_Renewal__c, 
                                                         Evergreen__c,
                                                         Apttus__Termination_Date__c FROM Apttus__APTS_Agreement__c WHERE 
                                                         Apttus__Status_Category__c != 'Terminated' AND 
                                                         Apttus__Status_Category__c != 'Expired' AND
                                                         Apttus__Status__c != 'Superseded' AND
                                                         RecordTypeId !=: recType1 AND RecordTypeId !=: recType2 AND RecordTypeId !=: recType3 AND
                                                         ( (Apttus__Termination_Date__c <=: Date.today()) OR 
                                                           (Apttus__Contract_End_Date__c <=: Date.today() AND (Apttus__Auto_Renewal__c != TRUE AND Evergreen__c != TRUE)) OR
                                                           (Apttus__Contract_End_Date__c =: Date.today()+7 AND (Apttus__Auto_Renewal__c != TRUE AND Evergreen__c != TRUE))
                                                         )];
        
        for(Apttus__APTS_Agreement__c agreement : allAgreements)
        {
            if(agreement.Apttus__Termination_Date__c <= Date.today()){
                agreement.Apttus__Status_Category__c = 'Terminated';
                agreementsToUpdate.add(agreement);
                if(!terminatedAgreementsMap.containsKey(agreement.OwnerId)){
                    List<Apttus__APTS_Agreement__c> termListAgreementsNotFound = new List<Apttus__APTS_Agreement__c>();
                    termListAgreementsNotFound.add(agreement);
                    terminatedAgreementsMap.put(agreement.OwnerId, termListAgreementsNotFound);
                }
                else{
                    List<Apttus__APTS_Agreement__c> termListAgreements = terminatedAgreementsMap.get(agreement.OwnerId);
                    termListAgreements.add(agreement);
                    terminatedAgreementsMap.put(agreement.OwnerId, termListAgreements);
                }
            }
            else if(agreement.Apttus__Contract_End_Date__c <= Date.today() && (agreement.Apttus__Auto_Renewal__c != true && agreement.Evergreen__c != true)){
                agreement.Apttus__Status_Category__c = 'Expired';
                agreementsToUpdate.add(agreement);
                /*if(!expiredAgreementsMap.containsKey(agreement.OwnerId)){
                    List<Apttus__APTS_Agreement__c> expListAgreementsNotFound = new List<Apttus__APTS_Agreement__c>();
                    expListAgreementsNotFound.add(agreement);
                    expiredAgreementsMap.put(agreement.OwnerId, expListAgreementsNotFound);
                }
                else{
                    List<Apttus__APTS_Agreement__c> expListAgreements = expiredAgreementsMap.get(agreement.OwnerId);
                    expListAgreements.add(agreement);
                    expiredAgreementsMap.put(agreement.OwnerId, expListAgreements);
                }*/
            }
            else if(agreement.Apttus__Contract_End_Date__c == Date.today()+7 && (agreement.Apttus__Auto_Renewal__c != true && agreement.Evergreen__c != true)){
                if(!almostExpiredAgreementsMap.containsKey(agreement.OwnerId)){
                    List<Apttus__APTS_Agreement__c> almExpListAgreementsNotFound = new List<Apttus__APTS_Agreement__c>();
                    almExpListAgreementsNotFound.add(agreement);
                    almostExpiredAgreementsMap.put(agreement.OwnerId, almExpListAgreementsNotFound);
                }
                else{
                    List<Apttus__APTS_Agreement__c> almExpListAgreements = almostExpiredAgreementsMap.get(agreement.OwnerId);
                    almExpListAgreements.add(agreement);
                    almostExpiredAgreementsMap.put(agreement.OwnerId, almExpListAgreements);
                }
            }
        }
        Map<Id, String> emailAddressesMap = new Map<Id, String>();
        List<User> listOwners = [SELECT Id, Email FROM User WHERE Id IN: terminatedAgreementsMap.keyset() OR Id IN: expiredAgreementsMap.keyset() OR Id IN: almostExpiredAgreementsMap.keyset()];
        if(!listOwners.isEmpty()){
            for(User u : listOwners){
                emailAddressesMap.put(u.Id, u.Email);
            }
        }
        for(Id idOfTheOwner : terminatedAgreementsMap.keySet()){
            Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
            message.toAddresses = new String[] {emailAddressesMap.get(idOfTheOwner)};
                message.subject = 'Terminated Agreement Notification';
            String bodyMessage = 'This notice is to inform you of the following terminated contract in NuCM:\r\n \r\n';
            Integer counter = 0;
            for(Apttus__APTS_Agreement__c agg : terminatedAgreementsMap.get(idOfTheOwner)){
                counter++;
                bodyMessage += counter+'. Agreement Number: '+agg.Apttus__FF_Agreement_Number__c+'\r\n\r\n';
                bodyMessage += 'Agreement Name: '+agg.Name+'\r\n\r\n';
                bodyMessage += 'Agreement End Date: '+String.valueOf(agg.Apttus__Termination_Date__c)+'\r\n\r\n\r\n';
            }
            bodyMessage += 'Please review the Agreement Record(s) and take any appropriate actions, if necessary.\r\n\r\nThank you!\r\nNuCM Admin Team';
            message.plainTextBody = bodyMessage;
            emailsToBeSent.add(message);
        }
        /*for(Id idOfTheOwner : expiredAgreementsMap.keySet()){
            Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
            message.toAddresses = new String[] {emailAddressesMap.get(idOfTheOwner)};
                message.subject = 'Expired Agreement Notification';
            String bodyMessage = 'This notice is to inform you of the following expired contract in NuCM:\r\n \r\n';
            Integer counter = 0;
            for(Apttus__APTS_Agreement__c agg : expiredAgreementsMap.get(idOfTheOwner)){
                counter++;
                bodyMessage += counter+'. Agreement Number: '+agg.Apttus__FF_Agreement_Number__c+'\r\n\r\n';
                bodyMessage += 'Agreement Name: '+agg.Name+'\r\n\r\n';
                bodyMessage += 'Agreement End Date: '+String.valueOf(agg.Apttus__Contract_End_Date__c)+'\r\n\r\n\r\n';
            }
            bodyMessage += 'Please review the Agreement Record(s) and take any appropriate actions, if necessary.\r\n\r\nThank you!\r\nNuCM Admin Team';
            message.plainTextBody = bodyMessage;
            emailsToBeSent.add(message);
        }*/
        for(Id idOfTheOwner : almostExpiredAgreementsMap.keySet()){
            Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
            message.toAddresses = new String[] {emailAddressesMap.get(idOfTheOwner)};
                message.subject = '7 Days From Expiration Of Agreement';
            String bodyMessage = 'This notice is to inform you that the following agreements will expire in 7 days in NuCM:\r\n \r\n';
            Integer counter = 0;
            for(Apttus__APTS_Agreement__c agg : almostExpiredAgreementsMap.get(idOfTheOwner)){
                counter++;
                bodyMessage += counter+'. Agreement Number: '+agg.Apttus__FF_Agreement_Number__c+'\r\n\r\n';
                bodyMessage += 'Agreement Name: '+agg.Name+'\r\n\r\n';
                bodyMessage += 'Agreement End Date: '+String.valueOf(agg.Apttus__Contract_End_Date__c)+'\r\n\r\n\r\n';
            }
            bodyMessage += 'Please review the Agreement Record(s) and take any appropriate actions, if necessary. The agreement status will change to expired on the Agreement End Date.\r\n\r\nThank you!\r\nNuCM Admin Team';
            message.plainTextBody = bodyMessage;
            emailsToBeSent.add(message);
        }
        update agreementsToUpdate;
        Messaging.SendEmailResult[] results = Messaging.sendEmail(emailsToBeSent);
        /*if (results[0].success) {
            System.debug('The email was sent successfully.');
        } else {
            System.debug('The email failed to send: '
                         + results[0].errors[0].message);
        }*/
        /*system.debug('Agreements to be updated: '+agreementsToUpdate);
system.debug('Number of Agreements to be updated: '+agreementsToUpdate.size());
system.debug('Emails to be sent: '+emailsToBeSent);
system.debug('Number of Emails to be sent: '+emailsToBeSent.size());*/
    }
}

 
I am trying to add a DateCreated to my validation rule. Without the added date piece, I receive a valid validation error, but when the datecreated piece is added I instead recieve error message: Upsert failed. First exception on row 0 with id a014B000006vdUXQAY; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please complete all Cyber Due Diligence questions!: [].
 
AND(
Due_Diligence_Status__c = "Not Requested",
DATEVALUE(CreatedDate) >= Date(2020,08,18),
OR(
ISBLANK(TEXT(Answer_Question_1__c)),
ISBLANK(TEXT(Answer_Question_2__c)),
ISBLANK(TEXT(Answer_Question_3__c)),
ISBLANK(TEXT(Answer_Question_4__c))
))

 
Hello, I am fairly new to this and need help with this Visualforce Code and Controller for excel export for multiple workbooks. I was able to find this online and made a few tweaks to make it work. With the code I am able to populate columns and rows fine and even the workbook, but what I am wanting is to be able to filter each workbook separately. Example, for "Canada", I want to use Region__c = "Canada". Please Help.

Vfpage
<apex:page controller="ExportToExcelMultipleSheets" contentType="txt/xml#myTest.xls" cache="true">

    <apex:outputText value="{!xlsHeader}"/>

    <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"

    xmlns:o="urn:schemas-microsoft-com:office:office"

    xmlns:x="urn:schemas-microsoft-com:office:excel"

    xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"

    xmlns:html="http://www.w3.org/TR/REC-html40&#8221">;
                
   <Styles>

   <Style ss:ID="s1">

   <Alignment/>

   <Borders/>

   <Font ss:Bold="1"/>

   <Interior/>

    <NumberFormat/>

    <Protection/>

     </Style>

   </Styles>

  <Worksheet ss:Name="Canada">

  <Table x:FullColumns="1" x:FullRows="1">

  <Column ss:Width="170"/>

  <Row>

<Cell ss:StyleID="s1"><Data ss:Type="String">Region</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Terminal Location</Data></Cell>      

<Cell ss:StyleID="s1"><Data ss:Type="String">Agreement Name</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Legacy Agreement Name</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Status Category</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Status</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">NuCM Number</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Agreement Type</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Start Date</Data></Cell>

<Cell ss:StyleID="s1"><Data ss:Type="String">End Date</Data></Cell>

<Cell ss:StyleID="s1"><Data ss:Type="String">Days Remaining on Contract</Data></Cell>      

<Cell ss:StyleID="s1"><Data ss:Type="String">Renewal Notice</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Renewal Term</Data></Cell>      

<Cell ss:StyleID="s1"><Data ss:Type="String">Description of Services</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Products</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Tank #</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Tank Cap.</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Combined Space</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Monthly Base or Minimum Thruput</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Full Record Id</Data></Cell>

<Cell ss:StyleID="s1"><Data ss:Type="String">Link to Salesforce</Data></Cell>
     
  </Row>

  <apex:repeat value="{!AgreementList}" var="account">

  <Row>

<Cell><Data ss:Type="String">{!account.Region__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Terminal_Location__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Name}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Legacy_Agreement_Number__c}</Data></Cell>

<Cell><Data ss:Type="String">{!account.Apttus__Status_Category__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Apttus__Status__c}</Data></Cell>

<Cell><Data ss:Type="String">{!account.Apttus__Agreement_Number__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Agreement_Type__c}</Data></Cell> 
      
<Cell><Data ss:Type="String">{!account.Apttus__Contract_Start_Date__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Apttus__Contract_End_Date__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Days_Remaining_on_Contract__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Apttus__Renewal_Notice_Days__c}</Data></Cell>

<Cell><Data ss:Type="String">{!account.Apttus__Renewal_Notice_Date__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Apttus__Auto_Renew_Term_Months__c}</Data></Cell>

<Cell><Data ss:Type="String">{!account.Description_of_Services__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Products__c}</Data></Cell>       

<Cell><Data ss:Type="String">{!account.Tank_s_if_segregated_storage__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Tank_Capacity__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Combined_Space__c}</Data></Cell>

<Cell><Data ss:Type="String">{!account.Monthly_Base_or_Minimum_Thruput_Revenue__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Full_Record_Id__c}</Data></Cell>    
      
</Row>

</apex:repeat>

</Table>

</Worksheet>
        
<Worksheet ss:Name="North East">

  <Table x:FullColumns="1" x:FullRows="1">

  <Column ss:Width="170"/>

  <Row>

<Cell ss:StyleID="s1"><Data ss:Type="String">Region</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Terminal Location</Data></Cell>      

<Cell ss:StyleID="s1"><Data ss:Type="String">Agreement Name</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Legacy Agreement Name</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Status Category</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Status</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">NuCM Number</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Agreement Type</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Start Date</Data></Cell>

<Cell ss:StyleID="s1"><Data ss:Type="String">End Date</Data></Cell>

<Cell ss:StyleID="s1"><Data ss:Type="String">Days Remaining on Contract</Data></Cell>      

<Cell ss:StyleID="s1"><Data ss:Type="String">Renewal Notice</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Renewal Term</Data></Cell>      

<Cell ss:StyleID="s1"><Data ss:Type="String">Description of Services</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Products</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Tank #</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Tank Cap.</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Combined Space</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Monthly Base or Minimum Thruput</Data></Cell>
      
<Cell ss:StyleID="s1"><Data ss:Type="String">Full Record Id</Data></Cell>

<Cell ss:StyleID="s1"><Data ss:Type="String">Link to Salesforce</Data></Cell>
     
  </Row>

  <apex:repeat value="{!AgreementList}" var="account">

  <Row>

<Cell><Data ss:Type="String">{!account.Region__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Terminal_Location__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Name}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Legacy_Agreement_Number__c}</Data></Cell>

<Cell><Data ss:Type="String">{!account.Apttus__Status_Category__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Apttus__Status__c}</Data></Cell>

<Cell><Data ss:Type="String">{!account.Apttus__Agreement_Number__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Agreement_Type__c}</Data></Cell> 
      
<Cell><Data ss:Type="String">{!account.Apttus__Contract_Start_Date__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Apttus__Contract_End_Date__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Days_Remaining_on_Contract__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Apttus__Renewal_Notice_Days__c}</Data></Cell>

<Cell><Data ss:Type="String">{!account.Apttus__Renewal_Notice_Date__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Apttus__Auto_Renew_Term_Months__c}</Data></Cell>

<Cell><Data ss:Type="String">{!account.Description_of_Services__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Products__c}</Data></Cell>       

<Cell><Data ss:Type="String">{!account.Tank_s_if_segregated_storage__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Tank_Capacity__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Combined_Space__c}</Data></Cell>

<Cell><Data ss:Type="String">{!account.Monthly_Base_or_Minimum_Thruput_Revenue__c}</Data></Cell>
      
<Cell><Data ss:Type="String">{!account.Full_Record_Id__c}</Data></Cell>    
      
</Row>

</apex:repeat>

</Table>

</Worksheet>        

</Workbook>    

</apex:page>
Apex Class
 
public class ExportToExcelMultipleSheets {

public List<Apttus__APTS_Agreement__c> AgreementList{get;set;}

public String xlsHeader{
    
    
    get{

        String strHeader;

        strHeader += '<?xml version="1.0"?>';

        strHeader += '<?mso-application progid=”Excel.Sheet”?>';

        return strHeader;
        
           }

}

public ExportToExcelMultipleSheets(){

    AgreementList = [select Name,Region__c,Terminal_Location__c,Legacy_Agreement_Number__c,Apttus__Status_Category__c,Apttus__Status__c,Apttus__Agreement_Number__c,Agreement_Type__c,Apttus__Contract_Start_Date__c,Apttus__Contract_End_Date__c,Days_Remaining_on_Contract__c,Apttus__Renewal_Notice_Days__c,Apttus__Renewal_Notice_Date__c,Apttus__Auto_Renew_Term_Months__c,Description_of_Services__c,Products__c,Tank_s_if_segregated_storage__c,Tank_Capacity__c,Combined_Space__c,Monthly_Base_or_Minimum_Thruput_Revenue__c,Full_Record_Id__c,Id from Apttus__APTS_Agreement__c LIMIT 500];
  

}
}

 
I have recently taken over as the admin and I am going through all of the currenty Apex Classes and have stumbled upon one that I can't seem to properly test for confirmation purposes. This particular class is suppose to be responsible for auto-expiring and terminating contracts based on the given criteria. When I create test records with the suspected criteria, the trigger seems to not happen, the records status' do not change. I don't know what I'm missing or if it's something in the code itself. The criteria for the test that I perform is below, and I typically set the record to expire or terminate the very next day. Please help me understand what this class is suppose to do!!!

Agreement Expiration
1.   All Record Types excluding ‘ Bulk Purchase Contract’, Bulk Sales Contract’, and ‘Bunker Sales Contract’.
2.  Agreement End Date: Today
3.  Auto Renew: False
4.  Evergreen: False
5.  Agreement Status: Does not equal to ‘Expired’ or ‘Terminated’.
*Once the Agreement End date occurs, the status of the record should update to Expired.

Agreement Termination
1.   All Record Types excluding ‘ Bulk Purchase Contract’, Bulk Sales Contract’, and ‘Bunker Sales Contract’.
2.   Agreement Status: Does not equal to ‘Expired’ or ‘Terminated’.
3.   Termination Date = Today
*Once the Termination Date occurs, the status of the record should update to Terminated.

Here is the Code.
 
global class AgreementNotifierScheduler implements Schedulable {
    global void execute(SchedulableContext ctx) {
        Map<Id, List<Apttus__APTS_Agreement__c>> expiredAgreementsMap = new Map<Id, List<Apttus__APTS_Agreement__c>>();
        Map<Id, List<Apttus__APTS_Agreement__c>> terminatedAgreementsMap = new Map<Id, List<Apttus__APTS_Agreement__c>>();
        Map<Id, List<Apttus__APTS_Agreement__c>> almostExpiredAgreementsMap = new Map<Id, List<Apttus__APTS_Agreement__c>>();
        Id recType1 = Schema.SObjectType.Apttus__APTS_Agreement__c.getRecordTypeInfosByName().get('Bulk Purchase Contract').getRecordTypeId();
        Id recType2 = Schema.SObjectType.Apttus__APTS_Agreement__c.getRecordTypeInfosByName().get('Bulk Sales Contract').getRecordTypeId();
        Id recType3 = Schema.SObjectType.Apttus__APTS_Agreement__c.getRecordTypeInfosByName().get('Bunker Sales Contract').getRecordTypeId();
        List<Messaging.SingleEmailMessage> emailsToBeSent = new List<Messaging.SingleEmailMessage>();
        List<Apttus__APTS_Agreement__c> agreementsToUpdate = new List<Apttus__APTS_Agreement__c>();
        List<Apttus__APTS_Agreement__c> allAgreements = [SELECT Id, 
                                                         OwnerId, 
                                                         Name,
                                                         Apttus__FF_Agreement_Number__c,
                                                         Apttus__Contract_End_Date__c, 
                                                         Apttus__Auto_Renewal__c, 
                                                         Evergreen__c,
                                                         Apttus__Termination_Date__c FROM Apttus__APTS_Agreement__c WHERE 
                                                         Apttus__Status_Category__c != 'Terminated' AND 
                                                         Apttus__Status_Category__c != 'Expired' AND
                                                         Apttus__Status__c != 'Superseded' AND
                                                         RecordTypeId !=: recType1 AND RecordTypeId !=: recType2 AND RecordTypeId !=: recType3 AND
                                                         ( (Apttus__Termination_Date__c <=: Date.today()) OR 
                                                           (Apttus__Contract_End_Date__c <=: Date.today() AND (Apttus__Auto_Renewal__c != TRUE AND Evergreen__c != TRUE)) OR
                                                           (Apttus__Contract_End_Date__c =: Date.today()+7 AND (Apttus__Auto_Renewal__c != TRUE AND Evergreen__c != TRUE))
                                                         )];
        
        for(Apttus__APTS_Agreement__c agreement : allAgreements)
        {
            if(agreement.Apttus__Termination_Date__c <= Date.today()){
                agreement.Apttus__Status_Category__c = 'Terminated';
                agreementsToUpdate.add(agreement);
                if(!terminatedAgreementsMap.containsKey(agreement.OwnerId)){
                    List<Apttus__APTS_Agreement__c> termListAgreementsNotFound = new List<Apttus__APTS_Agreement__c>();
                    termListAgreementsNotFound.add(agreement);
                    terminatedAgreementsMap.put(agreement.OwnerId, termListAgreementsNotFound);
                }
                else{
                    List<Apttus__APTS_Agreement__c> termListAgreements = terminatedAgreementsMap.get(agreement.OwnerId);
                    termListAgreements.add(agreement);
                    terminatedAgreementsMap.put(agreement.OwnerId, termListAgreements);
                }
            }
            else if(agreement.Apttus__Contract_End_Date__c <= Date.today() && (agreement.Apttus__Auto_Renewal__c != true && agreement.Evergreen__c != true)){
                agreement.Apttus__Status_Category__c = 'Expired';
                agreementsToUpdate.add(agreement);
                /*if(!expiredAgreementsMap.containsKey(agreement.OwnerId)){
                    List<Apttus__APTS_Agreement__c> expListAgreementsNotFound = new List<Apttus__APTS_Agreement__c>();
                    expListAgreementsNotFound.add(agreement);
                    expiredAgreementsMap.put(agreement.OwnerId, expListAgreementsNotFound);
                }
                else{
                    List<Apttus__APTS_Agreement__c> expListAgreements = expiredAgreementsMap.get(agreement.OwnerId);
                    expListAgreements.add(agreement);
                    expiredAgreementsMap.put(agreement.OwnerId, expListAgreements);
                }*/
            }
            else if(agreement.Apttus__Contract_End_Date__c == Date.today()+7 && (agreement.Apttus__Auto_Renewal__c != true && agreement.Evergreen__c != true)){
                if(!almostExpiredAgreementsMap.containsKey(agreement.OwnerId)){
                    List<Apttus__APTS_Agreement__c> almExpListAgreementsNotFound = new List<Apttus__APTS_Agreement__c>();
                    almExpListAgreementsNotFound.add(agreement);
                    almostExpiredAgreementsMap.put(agreement.OwnerId, almExpListAgreementsNotFound);
                }
                else{
                    List<Apttus__APTS_Agreement__c> almExpListAgreements = almostExpiredAgreementsMap.get(agreement.OwnerId);
                    almExpListAgreements.add(agreement);
                    almostExpiredAgreementsMap.put(agreement.OwnerId, almExpListAgreements);
                }
            }
        }
        Map<Id, String> emailAddressesMap = new Map<Id, String>();
        List<User> listOwners = [SELECT Id, Email FROM User WHERE Id IN: terminatedAgreementsMap.keyset() OR Id IN: expiredAgreementsMap.keyset() OR Id IN: almostExpiredAgreementsMap.keyset()];
        if(!listOwners.isEmpty()){
            for(User u : listOwners){
                emailAddressesMap.put(u.Id, u.Email);
            }
        }
        for(Id idOfTheOwner : terminatedAgreementsMap.keySet()){
            Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
            message.toAddresses = new String[] {emailAddressesMap.get(idOfTheOwner)};
                message.subject = 'Terminated Agreement Notification';
            String bodyMessage = 'This notice is to inform you of the following terminated contract in NuCM:\r\n \r\n';
            Integer counter = 0;
            for(Apttus__APTS_Agreement__c agg : terminatedAgreementsMap.get(idOfTheOwner)){
                counter++;
                bodyMessage += counter+'. Agreement Number: '+agg.Apttus__FF_Agreement_Number__c+'\r\n\r\n';
                bodyMessage += 'Agreement Name: '+agg.Name+'\r\n\r\n';
                bodyMessage += 'Agreement End Date: '+String.valueOf(agg.Apttus__Termination_Date__c)+'\r\n\r\n\r\n';
            }
            bodyMessage += 'Please review the Agreement Record(s) and take any appropriate actions, if necessary.\r\n\r\nThank you!\r\nNuCM Admin Team';
            message.plainTextBody = bodyMessage;
            emailsToBeSent.add(message);
        }
        /*for(Id idOfTheOwner : expiredAgreementsMap.keySet()){
            Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
            message.toAddresses = new String[] {emailAddressesMap.get(idOfTheOwner)};
                message.subject = 'Expired Agreement Notification';
            String bodyMessage = 'This notice is to inform you of the following expired contract in NuCM:\r\n \r\n';
            Integer counter = 0;
            for(Apttus__APTS_Agreement__c agg : expiredAgreementsMap.get(idOfTheOwner)){
                counter++;
                bodyMessage += counter+'. Agreement Number: '+agg.Apttus__FF_Agreement_Number__c+'\r\n\r\n';
                bodyMessage += 'Agreement Name: '+agg.Name+'\r\n\r\n';
                bodyMessage += 'Agreement End Date: '+String.valueOf(agg.Apttus__Contract_End_Date__c)+'\r\n\r\n\r\n';
            }
            bodyMessage += 'Please review the Agreement Record(s) and take any appropriate actions, if necessary.\r\n\r\nThank you!\r\nNuCM Admin Team';
            message.plainTextBody = bodyMessage;
            emailsToBeSent.add(message);
        }*/
        for(Id idOfTheOwner : almostExpiredAgreementsMap.keySet()){
            Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
            message.toAddresses = new String[] {emailAddressesMap.get(idOfTheOwner)};
                message.subject = '7 Days From Expiration Of Agreement';
            String bodyMessage = 'This notice is to inform you that the following agreements will expire in 7 days in NuCM:\r\n \r\n';
            Integer counter = 0;
            for(Apttus__APTS_Agreement__c agg : almostExpiredAgreementsMap.get(idOfTheOwner)){
                counter++;
                bodyMessage += counter+'. Agreement Number: '+agg.Apttus__FF_Agreement_Number__c+'\r\n\r\n';
                bodyMessage += 'Agreement Name: '+agg.Name+'\r\n\r\n';
                bodyMessage += 'Agreement End Date: '+String.valueOf(agg.Apttus__Contract_End_Date__c)+'\r\n\r\n\r\n';
            }
            bodyMessage += 'Please review the Agreement Record(s) and take any appropriate actions, if necessary. The agreement status will change to expired on the Agreement End Date.\r\n\r\nThank you!\r\nNuCM Admin Team';
            message.plainTextBody = bodyMessage;
            emailsToBeSent.add(message);
        }
        update agreementsToUpdate;
        Messaging.SendEmailResult[] results = Messaging.sendEmail(emailsToBeSent);
        /*if (results[0].success) {
            System.debug('The email was sent successfully.');
        } else {
            System.debug('The email failed to send: '
                         + results[0].errors[0].message);
        }*/
        /*system.debug('Agreements to be updated: '+agreementsToUpdate);
system.debug('Number of Agreements to be updated: '+agreementsToUpdate.size());
system.debug('Emails to be sent: '+emailsToBeSent);
system.debug('Number of Emails to be sent: '+emailsToBeSent.size());*/
    }
}

 
I am trying to add a DateCreated to my validation rule. Without the added date piece, I receive a valid validation error, but when the datecreated piece is added I instead recieve error message: Upsert failed. First exception on row 0 with id a014B000006vdUXQAY; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please complete all Cyber Due Diligence questions!: [].
 
AND(
Due_Diligence_Status__c = "Not Requested",
DATEVALUE(CreatedDate) >= Date(2020,08,18),
OR(
ISBLANK(TEXT(Answer_Question_1__c)),
ISBLANK(TEXT(Answer_Question_2__c)),
ISBLANK(TEXT(Answer_Question_3__c)),
ISBLANK(TEXT(Answer_Question_4__c))
))

 
Hi guys, is there a global search in Lightning similar to Classic that use &startURL=/_ui/search/ui/UnifiedSearchResults?str=valueToSearch ?.
If you know something please let me know. Thank you.

-Austin