Email template / text macro questions

edited June 14, 2018 in Questions
I have a question that I am hoping someone can help me with.

We have a button in Salesforce that is used for sending an email to the Account team. When you click the button, it loads a page that pre-populates with a Salesforce email template.

I'm able to get the Skuid page working for the email portion, and I am able to get the relevant To, From, CC, etc information from the Case model.

However, I ran into difficulty when I tried this:
  • I added a model called EmailTemplate, where the condition is set to a specific email template ID.
  • I set the body of the UI Only model (for the email) to lookup that EmailTemplate model and set it to the template body.
  • Upon loading the page, I see the template in the body (great!) but it doesn't handle the Salesforce merge fields
  • It looks like this:Β 
  • image
This all brings me to my question:

Is there a best way to handle something like this? I'm basically looking to be able to pre-populate the body of an email with contextual information from a case, but I may have several templates I need to work with.

Thanks!


Comments

  • Matt SonesMatt Sones πŸ’ŽπŸ’ŽπŸ’Ž
    edited June 13, 2018
    Korey,

    That's going to be pretty tricky. You're probably better off re-creating your template in Skuid with a richtext component or a ui-only formula field instead of asking skuid to parse the salesforce fields withing the existing template.
  • edited June 14, 2018
    Matt, thanks for responding! I can definitely do that, I don't mind re-making the templates, but what would be the best way to pre-populate (or populate after clicking a button) the body field?

    If I change the UI model to a single value, instead of a lookup of another model and paste in the template I want to use, it strips all of the carriage returns and line feeds so it's just one long run on sentence.

    image


  • edited June 14, 2018
    Ok, I believe I was able to sort this out.

    For anyone else who needs it. I followed this originally to get where I was at the beginning of the thread:Β https://community.skuid.com/skuid/topics/skuid-page-for-send-an-email

    Once I got there I wanted to set a default value based on pre-defined text. As Matt pointed out above it was tricky, so I've basically done this:


    To send the email I open a popup, so I added a javascript snippet action that runs prior to opening up the popup.

    var field = arguments[0];
    var value = arguments[1];

    var template = 'Say hello to

    multi-line

    strings!';

    var model = skuid.model.getModel('Email');
    var row = model.getFirstRow();
    model.updateRow(row,{Body: template});


    The
    is important, because if I set the pre-defined value of "Body" in the UI model, it returns as one giant line. Thinking about it as I type this, I could maybe do
    inside the pre-defined value, but I know in the future I will want several templates to selectΒ  from.

    Last thing I need to do is make sure I can use merge fields in the template, but I suspect at most I'll have to load the case model and just get the values.

    Hopefully that helps someone else.
  • Matt SonesMatt Sones πŸ’ŽπŸ’ŽπŸ’Ž
    edited June 14, 2018
    Nice work.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!