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
SathishKumarSathishKumar 

Time Dependant Email Alert

I have 2 objects Account and Contract(custom).
On Account i have created custom field Email to capture email address.
Account is master and Contract is child.
Contract is having a picklist called status which has 2 values(Pending, Executed) and date field.
Now i want to trigger a email alert to Account's email, if the contract status is pending.
Email alert to be triggered before 2, 5 and 10 days of date value.

I have created required email template.
created work flow rule on Contract, evaluation criteria is (Contract:  StatusNOT EQUAL TOExecuted).
While creating Email alert on HCP contract i am unable to see Account's Email field(custom).
Any help is appreciated.
Thanks in advance.
v varaprasadv varaprasad
Hi Sathish,

The relationship between account and contract is look up or master-detail.
If the relationship is master-detail you can see account email.In look up you cannot see parent fields. 



Hope this helps you!

Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com


 
SathishKumarSathishKumar
Hi Varaprasad,

The relationship is lookup, how can we acheive this.
Need your help
Thanks in advance.
v varaprasadv varaprasad
Hi Satish,

create one custom field in contract like copyemailfromacc__c in the backend. and write below trigger in contract object.
it will capture account email then you can use this field in an email alert.
 
trigger copyAccontEmail on contract__c(before insert,before update){
   
   set<id> accIds = new set<id>();
   for(contract__c cp  : trigger.new){
       if(cp.accountid != null){
	     accIds.add(cp.accountid);
	   }
   
   }
   
   list<account> lstAccs = [select id,email from account where id in : accIds and email != null];
   map<id,email> mapAccData = new map<id,account>
   for(account acc : lstAccs){
      mapAccData.put(acc.id,acc.email);	 
   
   }
   
   if(mapAccData.size() > 0 )
   for(contract__c cp  : trigger.new){
         if(mapAccData.containskey(cp.accountid)){
		    cp.copyemailfromacc__c  = mapAccData.get(cp.accountid);
		 }
      }
   


}

I have not tested above trigger may you will get some syntactical errors.



    Hope this helps you!

    Thanks
    Varaprasad
    For Support: varaprasad4sfdc@gmail.com