
Hi ECorona,I trust you are doing very well. It is a pleasure to be in touch with you again.Please try the below code. Kindly modify the code as per your requirement.Parent sObject : Test1__c Field (DateTime) : Dt__c
ChildsObject : Account
Field (DateTime) : Schedule__c
Lookup (Test1__c) : Test1__cTrigger:
I hope it helps you.Kindly let me inform if it helps you and close your query by marking it as solved so that it can help others in future.trigger DateTimeT on Account (after insert, after update) {
Map<ID, Test1__c> parentOpps = new Map<ID, Test1__c>();
List<Id> listIds = new List<Id>();
for (Account childObj : Trigger.new) {
listIds.add(childObj.Test1__c);
}
parentOpps = new Map<Id, Test1__c>([SELECT Id, Dt__c FROM Test1__c WHERE ID IN :listIds]);
List<Test1__c> updatedParentOpps = new List<Test1__c>();
for (Account con: Trigger.new){
if(parentOpps.containsKey(con.Test1__c)) {
Test1__c myAccount = parentOpps.get(con.Test1__c);
if(con.Schedule__c!=null) {
myAccount.Dt__c = con.Schedule__c;
updatedParentOpps.add(myAccount);
}
}
}
if(parentOpps.size()>0){
update parentOpps.values();
}
}
Thanks and Regards,
Khan Anas