Free cookie consent management tool by TermsFeed

MS Word 2007 Doc from Template Smart Service

On This Page

About MS Word 2007 Doc from Template

The MS Word 2007 Doc from Template smart service generates a Microsoft Office 2007 (or Office 2010) Word document populated with process data.

The MS Word 2007 Doc from Template smart service uses a Microsoft Word document template in .docx format. To create the merge template, edit a Microsoft Word 2007/2010 document and identify each merge field by enclosing the field with three pound symbols (###).

Sample Word template

Name: word_template.docx

Content:

1
2
###Name###. joined ###Department###. on ###Date of Joining###. The employee's position is ###Position###. and their
supervisor is ### Supervisor###.

When you have created your template, upload the template file to a folder in Appian's document management. You can also upload alternate templates, which can be selected at runtime using a rule or an expression.

Requirements for MS Word 2007 Doc from Template

To use the MS Word 2007 Doc from Template smart service, the following requirements must be met:

  • Template format: The template must be a .docx file uploaded to an Appian folder.
  • Permissions: The smart service initiator must have Author rights to the folder holding the template.. If the smart service initiator does not have the proper rights, the smart service generates an error message for the process administrator and pauses the process.
  • Spelling and grammar: Template substitution keys must pass Microsoft Word's spelling and grammar tests. When viewing the template in Microsoft Word, right-click each substitution key and select Ignore for any spelling or grammar issues that are listed.
  • Contiguous formatting: Any text formatting must be contiguously applied to the entire substitution key, and not any partial section of the key. Formatting creates XML tags in the template that render the substitution key unrecognizable if an opening or closing tag falls within the key.

MS Word 2007 Doc from Template node

To configure the MS Word 2007 Doc from Template node, use the Setup tab and the Data tab. See Process Node and Smart Service Properties for common node configurations.

Node properties

The MS Word 2007 Doc from Template node has the following properties:

Configure the Setup tab

The Setup tab is the primary location for configuring the MS Word 2007 Doc from Template node. Use this tab to specify the template document, configure substitution key mappings, and set the output destination.

Scroll or drag to pan · ⌘+/⌘− to zoom · Esc to closeSetup tab of MS Word 2007 Doc from Template smart service

To configure the MS Word 2007 Doc from Template setup tab:

  1. Complete the following fields:

    Field Action
    Template Select your merge template from an Appian folder. To browse the available folders, click the Directory button. The Choose a document dialog is displayed. Select a document. Only documents that have a .docx extension are listed. You can also type the name of the document. Once a document has been selected, the substitution keys in the document are scanned and appear in the substitution grid. Any formatting applied to a substitution key must be contiguous, meaning the formatting cannot be applied to some characters and not others.
    Runtime Template (Optional) Enter an expression that specifies a document using a variable or a constant. You can create constants that contain each desired template. The substitution keys in the runtime template(s) do not have to match the base template exactly, but any keys used in the runtime template must be present in the base template.
    Destination Select whether you want the smart service to create a new document or update an existing document. Your selection determines which additional fields you must complete.
  2. If you selected the Create a new file option, complete the following fields:

    Field Action
    New document name Enter the name of the new document that the smart service creates. You can type the name into the text field, or specify a name through an expression by clicking Open the Expression Editor. Avoid characters that are disallowed (such as / \ : ; < > " * ' ?).
    New document description Enter a brief description of the document. The Expression Editor can also be used to formulate a description.
    Save in folder Select the folder where the newly created document is to be stored. Once you have selected a folder, click Validate to check the name of the folder specified. You can also use an expression or a rule to select a folder at runtime.
  3. If you selected the Overwrite an existing document option, complete the following fields:

    Field Action
    Document to replace Specify the document to be updated. Click Directory to browse for a document. You can also look up the document using autocomplete by typing the document name in the text field.
    Replace with Assign a process variable, constant, or typed value for each replacement key listed. Substitution values can contain HTML formatting tags, such as <i> or <b>, or the characters &, <, and >. The smart service safely escapes these special characters.
  4. If you have made changes to the template document, click Re-scan Template on the toolbar. The smart service rescans the template for substitution keys. Whenever the template path is changed, the smart service also parses the specified document for substitution keys.

Configure the Data tab

The Data tab for the MS Word 2007 Doc from Template node allows you to map the document output to a process variable for use elsewhere in the process model.

Configure node outputs

To configure the Outputs for the MS Word 2007 Doc from Template node:

  1. In your process model, open the MS Word 2007 Doc from Template node.
  2. Go to Data > Outputs.
  3. Select New Document Created on the Results list. The result properties display.
  4. Create a new process variable to store the result, or select an existing process variable with a Document data type from the available list.
Output Name Data Type Description
New Document Created Document The ID of the document that was created or replaced.

MS Word 2007 Doc from Template node examples

The following examples illustrate how to create process models using the MS Word 2007 Doc from Template node. The data used in these instructions is for example purposes only. Replace any example data with the data available in your application.

Generate an employee report with tenure and performance data

Goal: Populate a Word document with employee details for an annual performance report, including the employee's name, department, hire date, years of tenure, and performance review summary.

Word template

Name: employee_report_template.docx

Content:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Employee Performance Report

Name: ###EmployeeName###
Department: ###Department###
Hire Date: ###HireDate###
Years of Tenure: ###Tenure###

Performance Summary:
###PerformanceSummary###

Manager Comments:
###ManagerComments###

Report generated on ###ReportDate###.
Process variable mappings

The following table shows how to map each substitution key to a process variable or expression in the smart service configuration:

Substitution Key Value
EmployeeName pv!employeeFirstName & " " & pv!employeeLastName
Department pv!department
HireDate text(pv!hireDate, "MM/dd/yyyy")
Tenure tointeger(round(yearfrac(pv!hireDate, today(), 1), 0))
PerformanceSummary pv!performanceRating & " " & char(8212) & " " & pv!performanceSummary
ManagerComments if(isnull(pv!managerComments), "No comments provided.", pv!managerComments)
ReportDate text(today(), "MMMM dd, yyyy")

The char(8212) function inserts an em dash character between the performance rating and summary text.

Generate an insurance claim decision letter

Goal: Populate a Word document with claim details and a decision outcome for an insurance claim approval or denial letter, using conditional expressions to insert different content based on the claim decision.

Word template

Name: claim_decision_template.docx

Content:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
###InsuranceCompanyName###
###CompanyAddress###

###CurrentDate###

RE: Claim ###ClaimNumber### ###ClaimDecision###

Dear ###ClaimantName###,

###DecisionBody###

Claim Details:
  Policy Number: ###PolicyNumber###
  Date of Loss: ###DateOfLoss###
  Claim Amount: ###ClaimAmount###

###NextSteps###

Sincerely,
###AdjusterName###
Claims Department
Process variable mappings

The following table shows how to map each substitution key to a process variable or expression in the smart service configuration:

Substitution Key Value
InsuranceCompanyName pv!companyName
CompanyAddress pv!companyStreet & ", " & pv!companyCity & ", " & pv!companyState & " " & pv!companyZip
CurrentDate text(today(), "MMMM dd, yyyy")
ClaimNumber pv!claimNumber
ClaimDecision if(pv!isApproved, char(8212) & " APPROVED", char(8212) & " DENIED")
ClaimantName pv!claimantFirstName & " " & pv!claimantLastName
DecisionBody if(pv!isApproved, "We are pleased to inform you that your claim has been approved. Payment will be issued within 10 business days.", "After careful review, your claim has been denied. The reason for this decision is: " & pv!denialReason & ".")
PolicyNumber pv!policyNumber
DateOfLoss text(pv!dateOfLoss, "MM/dd/yyyy")
ClaimAmount a!currency(isoCode: "USD", value: pv!claimAmount)
NextSteps if(pv!isApproved, "No further action is required on your part.", "You may appeal this decision within 30 days by contacting our office at " & pv!appealPhone & ".")
AdjusterName pv!adjusterName

The char(8212) function inserts an em dash before the decision status in the subject line.

Using the MS Word 2007 Doc from Template smart service

The following considerations and behavior apply when you use the MS Word 2007 Doc from Template node in a process model.

Unicode support for MS Word 2007 Doc from Template

The MS Word 2007 Doc from Template node supports Unicode (UTF-8) templates and generates Unicode documents.

Control characters in substitution values

Do not use char() to insert control characters such as line breaks (char(10)) or carriage returns (char(13)) in substitution values. The smart service performs plain-text token substitution, and the .docx format requires specific XML markup for line breaks (such as <w:br/>). Word will ignore the control characters, so no line break appears in the generated document.

HTML in substitution values for MS Word 2007 Doc from Template

Substitution values can contain HTML formatting tags, such as <i> or <b>, or the characters &, <, and >. The smart service safely escapes these special characters in the output document.

Permission errors for MS Word 2007 Doc from Template

If the smart service node is run as a user who does not have adequate rights to the template document, the document that is to be replaced, or the folder where the new document is generated, an error message is sent to the process administrator and the task is paused.

Usage considerations

Run at low throughput in autoscaled processes

This smart service is not intended for high-throughput usage and should only be used at low frequency in processes with autoscale enabled. The underlying services this node relies on may not scale to the same degree as autoscale-enabled processes, which may impact performance at high concurrency.

For autoscaled processes, consider one or more of these approaches:

  • Position this node in less used paths within your process flow. This could be an exception path or an uncommon case for the process.
  • Monitor node execution times during performance testing to see if the node performs differently at scale.

When used in an autoscaled process, the node should behave as it would in a standard process of comparable scale. For typical workloads, no special design considerations are needed.

Feedback