You need to sign in to do that
Don't have an account?
cbro
Need to update lookupRecord field (Date/Time) when relatedRecord is created or updated
I need to update a custom Date/Time field on thelLookupRecord any time I create or update a relatedRecord.
How can I build a trigger to do this?
Here is the updated code. Fixed. Thanks to some help from my internal team. - Sonja, you almost had it - but I didn't do a good job explaining what I needed!
The Contract_Header__c field is just a text field. I have a Contract_Header_LOOKUP__c that is the lookup field - which is what I needed to make it work.
Well - I'm still trying to populate that lookup field, but once it is populated, I should be all good.
All Answers
Google apex date/time methods but here's an example:
myDateField__c = System.now();
or store it in a variable like :
Date myDate = System.now();
myDateField__c = myDate;
I need to build a trigger to do this whenever relatedRecord is created or updated.
Thanks,
You need to make the trigger (after insert, after update) What other criteria do you need in the trigger?
I need this Date/Time field on the lookupRecord to update every time the relatedRecord is updated or added.
Do I need to have an if statement for every field that could be updated on the Contract_Line__c - that then pushes over the DateTime to the Contract_Header__c?
or can I just simply send over the DateTime whenever this record is edited (saved/changed)...?
This is now where I am- and it's closer, and I am getting this error (Error: Compile Error: Didn't understand relationship 'Contract_Header__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 4 column 32):
Here is the updated code. Fixed. Thanks to some help from my internal team. - Sonja, you almost had it - but I didn't do a good job explaining what I needed!
The Contract_Header__c field is just a text field. I have a Contract_Header_LOOKUP__c that is the lookup field - which is what I needed to make it work.
Well - I'm still trying to populate that lookup field, but once it is populated, I should be all good.