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
MSVRadMSVRad 

Date Calculation Help - 2 date fields from different objects

I am trying to find the difference between two date fields. One date field: "Site_Start_Date__c" is from the standard Account object.  The second date field: "LOI_Received__c" is from a Custom object names " Go_Live_Process__c". The result field will have a return type of number and will be placed on an Account object page layout.
 
There is a master-detail relationship between Account and Go Live Process. I want to make sure that the field from Go_Live_Process__c matches up to the correct Account. I dont know if this is something that SF will take care of or if it is something that I have to take into consideration.
 
The equation I tried is:  Site_Start_Date__c - Go_Live_Process__c.LOI_Received__c
 
But I get errors saying that either Go_LIve_Process__c does not exist or LOI_Received__c does not exist and I should check my spelling.
 
I am not sure the best way to approach this. So far I have tried a Formula field, but maybe an apex trigger would work better?
Best Answer chosen by Admin (Salesforce Developers) 
JakesterJakester
The problem is that Salesforce can't compare "down the line" because it doesn't know which of the potentially many child Go_Live_Process__c records that you want to look at. You could, however, compare a specific date field on the Go_Live_Process__c record against the Account.Site_Start_Date__c field. That formula would obviously have to exist on the Go_Live_Process__.

All Answers

JakesterJakester
The problem is that Salesforce can't compare "down the line" because it doesn't know which of the potentially many child Go_Live_Process__c records that you want to look at. You could, however, compare a specific date field on the Go_Live_Process__c record against the Account.Site_Start_Date__c field. That formula would obviously have to exist on the Go_Live_Process__.
This was selected as the best answer
MSVRadMSVRad
Thanks a bunch this was really helpful