Email template / text macro questions

KoreyKorey Member
edited June 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.



  • Matt SonesMatt Sones Member ✭✭
    edited June 2018

    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.
  • KoreyKorey Member
    edited June 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.


  • KoreyKorey Member
    edited June 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:

    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



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

    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 Member ✭✭
    edited June 2018
    Nice work.
Sign In or Register to comment.