I need help in making the below scenario work . Below is the detailed explanation
On the child custom object we have custom button send email which sends email to the selected child records . Through custom send email button using url hacking i am making the subject of the email dynamic and i am prepopulating values from child object into the subject .
Below is the url
mailUrl = '_ui/core/email/author/EmailAuthor?p3_lkid='+parentId + '&p2_lkid='+finalEmail_To+'&p24='+finalEmail_AddtionalTo+'&p6=Deadline Notice – Action by:'+Actiondate+' ShowTitle :'+Title+' Person’s Last Name :'+Lastname+ '&p4='+finalEmail_CC+'&retURL=%2F'+parentId+'&template_id=00Xj0000000Ec9U';
This works great. When the custom send email button is clicked the subject is populated from the above url and the body of the email is populated from the template id stated in url above .
Now the challenge i am facing is after we click the custom send email button it takes us to the send email page where we see the select template button ,this page already has the subject and body populated but if the user clicks the select template button to select the same template in the url ,then it overrides the value in the subject line with the subject value in the visual force template.
Currently in the vf template i have set the subject to blank ,
In the vf template i need the relatedtotype to be set to parent object because we have a component and apex class running behind the vf email template that needs reference to the parent object to populate info in the body of the email.So now you can see why i chose url hacking to populate values in to the subject line since the relatedttype is set to parent object in the vf template which is why we cant get values from child object.
However like i said earlier that the only concern i am facing here is that when the user hits the select template button the subject value is set to blank , Is there a way to prevent the subject value from getting overridden and is there a way i can still retain the subject value coming from url even after the user manually selects the same template .
Any help would be highly appreciated.