1

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.

2
  • if you are passing the values along with template id from custom button then why are you navigating to the selection page? You can directly send the email from button click Jul 5, 2017 at 19:46
  • Thank you for looking into this one for me Santanu , Let me answer your question here :We have a use case where they should be able to change the email template ,say for example if they are selecting only one record then we have a different template that we want to send , so we still want our users to be able to select the email template ,
    – Natasha
    Jul 5, 2017 at 19:51

1 Answer 1

1

One option can be possible.

  • Create a custom subject text field in the Object.

  • Use this custom subject text in your email templates.

  • Update this custom subject text field in the Custom button send email call. So, before opening the send email page, the custom subject text field should have value which you are passing as URL.

Since, Salesforce always overrides the subject based on selected template, I think you could explore that kind of idea.

3
  • 1
    You are FABULOUS ! @santanu boral . This worked like a charm.
    – Natasha
    Jul 7, 2017 at 21:15
  • I just acceped this as best answer , not sure how to upvote for this one , If you could please guide , and once again many thanks !You are awesome .
    – Natasha
    Jul 7, 2017 at 21:17
  • when you have sufficient reputation you could do that. I never done this kind of requirement, but happy to know my idea got worked Jul 7, 2017 at 21:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .