• Share
    • Twitter
    • LinkedIn
    • Facebook
    • Email
  • Feedback
  • Edit
Show / Hide Table of Contents

How to use a reply template in CRMScript

•
Version: 10
Some tooltip text!
• 3 minutes to read
 • 3 minutes to read
  1. Declare and load the template
  2. Set up subject, body, and attachments in the selected language
  3. Bring in data values
  4. Run it through the parser

You can either use a built-in template or define your own.

Load template

To get started, you need to know the ID of the template to use. The available templates and their ID are specific to your tenant. Here's how to see what's available and find the ID:

  1. Sign in to SuperOffice Service.
  2. Click Knowledge Base in the main menu and select Reply templates.
  3. Select a template to view more info.
  4. While viewing the template you wish to use, get the ID from the URL. For example, ReplyTemplate&id=2.

Bool load(Integer id)

Retrieves the reply template with the given ID and loads it into the object.

ReplyTemplate rt;
rt.load(2);
print(rt.getName());

The getName() method simply returns the name of the loaded template.

Set up subject, body, and attachments

Before you can substitute variables for values, you must set up at least the subject and body. The body is available in 3 variants: plain, HTML, and SMS. The subject is plain text only.

String getSubject(Integer language)

Fetches the subject string in the selected language.

String subject = rt.getSubject(2);

String getPlainBody(Integer language)

Fetches the body string in the selected language as plain text.

String plainBody = rt.getPlainBody(2);

String getHtmlBody(Integer language)

Fetches the body string in the selected language as HTML.

String htmlBody = rt.getHtmlBody(2);

String getSmsBody(Integer language)

Fetches the body string in the selected language suitable for SMS.

Integer[] getAttachments(Integer language)

Fetches the ID of all attachments.

Bring in data values

Unlike all the other steps, this step depends on the individual template and which data it requires you to provide.

Let's say we need a ticket and a customer:

Ticket t;
t.load(getVariable("ticketId").toInteger());
t.toParser(p);

Customer c;
c.load(t.getValue("custId").toInteger());
c.toParser(p);

Run template through the parser

This is where the magic happens and the template variables are substituted. The parser is described in-depth elsewhere.

subject = p.parseString(subject);
plainBody = p.parseString(plainBody);
htmlBody = p.parseString(htmlBody);
In This Article
  • Load template
    • Bool load(Integer id)
  • Set up subject, body, and attachments
    • String getSubject(Integer language)
    • String getPlainBody(Integer language)
    • String getHtmlBody(Integer language)
    • String getSmsBody(Integer language)
    • Integer[] getAttachments(Integer language)
  • Bring in data values
  • Run template through the parser
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top