(Solved) Using S&M templates variables in a Service Reply Template - by script

Hi always awesome Community.

I'm trying to send out sms through script using only reply templates.

Its pretty easy to load a reply template, and get the sms body. But how do use already existing variables in the template to match a certain person and/or company?

I can create my own parsing variables, and do it with the Parser class, but I've no clue on how to use all the standard template variables :(.


ReplyTemplate rt;
String body = rt.getSmsBody(4);

RE: Using reply-templates by script

Hi Kasper,


Here is a snippet that I often use. Is this something you can use?

does this answer your question?

// Load reply template
  ReplyTemplate rt;
  String subject = rt.getSubject(customerLanguage);
  String bodyPlain = rt.getPlainBody(customerLanguage);
  String bodyHtml = rt.getHtmlBody(customerLanguage);

// Parse templates with customer and ticket
  Parser parser = getParser();
  subject = parser.parseString(subject);
  bodyPlain = parser.parseString(bodyPlain);
Av: Niels van Broekhoven 20. jul 2018

RE: Using reply-templates by script

Hi Niels.

This is not exactly what i want, but could be a solution.

What I'm going for, is to use the Sales & Marketing template variables instead. The sms is being send out on the basis of an Appointment, thus I have the relevant Sale, Project, Company and Contactperson. 

Av: Kasper Rosenlund 20. jul 2018

RE: Using reply-templates by script

Hello Kasper,

You can use the SubstituteTemplateVariables method in the NSDocumentAgent class for this.



#setLanguageLevel 3;

NSDocumentAgent documentAgent;

String orginalText = "Hello, Company <name>";

Integer encoding = 0; // see https://community.superoffice.com/documentation/sdk/SO.NetServer.Web.Services/html/T_SuperOffice_Data_GeneratorEncoding.htm

Integer contactId = 1055;
Integer personId = 0;
Integer appointmentId = 0;
Integer documentId = 0;
Integer saleId = 0;
Integer selectionId = 0;
Integer projectId = 0;

String cultureName = "";// empty is use current culture

String replacedText = documentAgent.SubstituteTemplateVariables(orginalText, encoding, contactId, personId, appointmentId, documentId, saleId, selectionId, projectId, cultureName);

Av: David Hollegien 20. jul 2018

RE: Using reply-templates by script

Hi David - this is exactly what I was looking for. THANK YOU! :)

Av: Kasper Rosenlund 20. jul 2018