+ Start a Discussion
nickfs92840nickfs92840 

Date Validation Rule to add dates to another date field?

Field Name: Date Sent 
API name: Date_Sent__c

Field Name: TAT
API name: TAT__c

Objective - Automatically add 15 days to "TAT" field from input made in the "Date Sent" field. 

 

"TAT" field, will be a read only field but "Date Sent"will be a "Date" Data Type.

 

Need a VR that will add 15 days from date input to be made from the "Date Sent" field and autopopulate the "TAT" field.

 

Please see screenshot for example: http://cl.ly/I9Ei

 

Thank you!

 

 

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

Hi,

 

 You can use custom formula field which will be read only field.

 

For creating a formula field in Accounts object follow the below steps:

 

 Your name->setup-> Customize-> Accounts-> Fields

Click on new button

Select formula in step 1 as Data Type

Click on next button

Enter the Field Name(TAT)

Select return type(Date) of formula field.

Click on next button

Specify formula criteria and follow the steps.

Date_Sent__c+ 15

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

All Answers

Navatar_DbSupNavatar_DbSup

Hi,

 

 You can use custom formula field which will be read only field.

 

For creating a formula field in Accounts object follow the below steps:

 

 Your name->setup-> Customize-> Accounts-> Fields

Click on new button

Select formula in step 1 as Data Type

Click on next button

Enter the Field Name(TAT)

Select return type(Date) of formula field.

Click on next button

Specify formula criteria and follow the steps.

Date_Sent__c+ 15

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

This was selected as the best answer
ssrssr
global class cEMS_SAP_Report_Scheduler Implements Schedulable
{
    global void execute(SchedulableContext sc)
   {
    cEMS_Controller_SAP cSAP = new cEMS_Controller_SAP();
    cSAP.init();
    List<Sap_Report_cems__c> lstSpekerReport = new List<Sap_Report_cems__c>();
    String strSpeakerReport = 'Event ID,Event Start Date,Event End Date,Department,Cost Center,Applicant name,Applicant Date,Order Type,Company Code,Controlling Area\n';            
    for(integer i =0 ;i < cSAP.lstWrapEvent.size();i++)
          {
            Sap_Report_cems__c src=new Sap_Report_cems__c();
            src.Event_ID_cems__c = cSAP.lstWrapEvent[i].EventId1;
            strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].EventId1 + ',';
            src.Event_Start_Date_cems__c = cSAP.lstWrapEvent[i].eventStartDate;
            strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].eventStartDate + ',';
            src.Event_End_Date_cems__c = cSAP.lstWrapEvent[i].EventendDate;
            strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].EventendDate + ',';
            src.Department_cems__c = cSAP.lstWrapEvent[i].Department;
            strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].Department + ',';
            src.Description_cems__c = cSAP.lstWrapEvent[i].Objectives;
            strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].Objectives + ',';
            src.Cost_Center_cems__c = cSAP.lstWrapEvent[i].Costcenter;
            strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].Costcenter + ',';
            src.Applicant_cems_ref__c = cSAP.lstWrapEvent[i].ApplicantId;
            strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].Applicant + ','; 
            src.Applicant_Date_cems__c = cSAP.lstWrapEvent[i].ApplicantDate;
            strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].ApplicantDate + ',';
            src.Order_type_cems__c = cSAP.lstWrapEvent[i].OrderType;
            strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].OrderType + ',';
            src.Company_code_cems__c = cSAP.lstWrapEvent[i].CompanyCode;
            strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].CompanyCode + ',';
            src.Controlling_Area_cems__c = cSAP.lstWrapEvent[i].ControllingArea;
            strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].ControllingArea + '\n';
            lstSpekerReport.add(src);
            }
            insert LstSpekerReport;           
         Document doc  = new document();
         doc.Name  = 'EMSSAP_' + system.now().format('dd/MM/yyyy hh:mm:ss') + '.csv';      
         doc.ContentType = 'text/csv';
         doc.body = blob.valueof(strSpeakerReport);
         doc.folderid = [select id from folder where name='cEMS_SAP_Report'].id; // Stores in the currennt users "My Personal 
         insert doc;
     }
}

 

global class cEMS_SAP_Report_Scheduler Implements Schedulable
{
    global void execute(SchedulableContext sc)
   {
    cEMS_Controller_SAP cSAP = new cEMS_Controller_SAP();
    cSAP.init();
    List<Sap_Report_cems__c> lstSpekerReport = new List<Sap_Report_cems__c>();
    String strSpeakerReport = 'Event ID,Event Start Date,Event End Date,Department,Cost Center,Applicant name,Applicant Date,Order Type,Company Code,Controlling Area\n';            
    for(integer i =0 ;i < cSAP.lstWrapEvent.size();i++)
          {
            Sap_Report_cems__c src = new Sap_Report_cems__c();
            src.Event_ID_cems__c = cSAP.lstWrapEvent[i].EventId1;
            strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].EventId1 + ',';
            src.Event_Start_Date_cems__c = cSAP.lstWrapEvent[i].eventStartDate;
            strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].eventStartDate + ',';
            src.Event_End_Date_cems__c = cSAP.lstWrapEvent[i].EventendDate;
            strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].EventendDate + ',';
            src.Department_cems__c = cSAP.lstWrapEvent[i].Department;
            strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].Department + ',';
            src.Description_cems__c = cSAP.lstWrapEvent[i].Objectives;
            strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].Objectives + ',';
            src.Cost_Center_cems__c = cSAP.lstWrapEvent[i].Costcenter;
            strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].Costcenter + ',';
            src.Applicant_cems_ref__c = cSAP.lstWrapEvent[i].ApplicantId;
            strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].Applicant + ','; 
            src.Applicant_Date_cems__c = cSAP.lstWrapEvent[i].ApplicantDate;
            strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].ApplicantDate + ',';
            src.Order_type_cems__c = cSAP.lstWrapEvent[i].OrderType;
            strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].OrderType + ',';
            src.Company_code_cems__c = cSAP.lstWrapEvent[i].CompanyCode;
            strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].CompanyCode + ',';
            src.Controlling_Area_cems__c = cSAP.lstWrapEvent[i].ControllingArea;
            strSpeakerReport = strSpeakerReport + cSAP.lstWrapEvent[i].ControllingArea + '\n';
            lstSpekerReport.add(src);
            }
            insert LstSpekerReport;           
         Document doc  = new document();
         doc.Name  = 'EMSSAP_' + system.now().format('dd/MM/yyyy hh:mm:ss') + '.csv';      
         doc.ContentType = 'text/csv';
         doc.body = blob.valueof(strSpeakerReport);
         doc.folderid = [select id from folder where name='cEMS_SAP_Report'].id; // Stores in the currennt users "My Personal 
         insert doc;
     }
}