Email template for the CASE module - How to use Account or Contact variables ?

Hello,

I was wondering if one of you already customize the variable replacement to extend the behavior.

My problem is the following : you can, through the EMAIL TEMPLATE module, create a template and add several variables, including :

  • Contact's variable : $contact_
  • Account's varable : $account_
  • Case's variable : $case_

The problem is that, depending on the module you use the feature, the substitution wont be done for "other module" variables.

In my scenario, when you use a custom template to answer to the customer of my case, you can use ALL cases variable but unfortunately none of the linked Account record neither the main Contact record.

Or course we can duplicate fields on the case but this solution is not really reliable (we are not going to duplicate any fields of the account and the contact).

So, before go ahead with our custom dev, I want to see if one of you solve this and maybe share the way you did it.

Regards,

Fred

  • hi  

    Maybe I've misunderstood, but don't you see the options you need when creating an email template like this screenshot?

    .

    CRM Business Consultant

  • Hello  ,

    Yes those options exist but if you add some Contact/Lead/Target to a template that will be use from a case to write an email, those variable won't be replaced. Only the case's one will be.

    So for instance, you want to create a template email for your support team, to provide a quick answer to a well known case.

    There is no easy way to create an email template that will says:

    Dear $main_contact_salutation $main_contact_name,

    We received your demande $case_name ($case_number) and here is our suggestion : xxxxx

    Of course we find where we could update the core code of Sugar to update the variable replacement process but I was hoping that they will be another solution (or maybe someone that could explains me how to use the email template module to do it).

    Fred

  •   

    Presuming you are sending the emails via the standard front end process then unfortunately it isn't possible to get fields off the parent Account when sending for Cases as far as I am aware, and I think its been that way for a while. This is because in \Email::sendEmail it sends the Email parent record (if set) and the current User to \EmailTemplate::parse_template so the Account / Contact bean would not be there.

    It does have some logic in that says if the bean being processed is Contacts then also parse the parent Account so you should find for emails sent with Contact as the parent but it doesn't appear to have been extended to support for Cases. Might be something to raise in the support portal as an idea as it would definitely be something that I'm sure many customers might want.

    It also skips relate fields from being parsed which would at least have let you use the Primary Contact name, though you should be able to use Relate Fields Denormalization to get the Primary Contact name onto the Case as a field to get that bit of your email working at least (I have never set that particular one up but it should work).

    As you said one option is to duplicate fields though its not ideal, and would mean if you change the data on Accounts it would have to potentially re-save all its related Cases which could be timely. If you only wanted the Account name then you could use the denorm_account_name field but from what I understand of your post you want field data off the Account itself which would require some customisation  around the Email send API endpoint to achieve.

    Sorry I couldn't give a more positive response and for this being such a lengthy answer I figured some specifics might help should you look into the code route. I am happy to be proven wrong about this if somebody has found something I have missed.