Create and Update Change Request (ServiceNow) - Jinja2 Template
  • 18 Oct 2024
  • Dark
    Light
  • PDF

Create and Update Change Request (ServiceNow) - Jinja2 Template

  • Dark
    Light
  • PDF

Article summary

Before we start building the lab exercise, we’re going to take a look at Jinja2 Templates. For those less familiar, Jinja2 is a templating language developed for Python that allows users to take structured data and format it for human readability. Here we’ll build a simple template that will show you how this is done. Part of today’s workflow will leverage a Jinja2 Template in order to format text for ServiceNow, so this small exercise will give you a better idea of how that workflow operates. 

Jinja2 Template Video

Step 1

From the IAP Dashboard, click Automation Studio

Step 2

Click the + at the top of the left navigation panel.

Step 3

The Create window opens. Click the dropdown and select Template

Step 4

Let’s give it a name of Template-XX and enter Workshop for Group.  For Type, click the dropdown and select Jinja2,

click Create.

Step 5

Using the sample JSON Data provided below, update the data on the left side of the screen, the JSON data side.

{
  "firstName": "",
  "title": "",
  "companyName": "",
  "repeatableTask": "",
  "vendorNames": []
}

Step 6

Let’s use the sample template text found on the course resource document and paste in on the right.

My name is {{ firstName }}, and I'm a(n) {{ title }}.
Here at {{ companyName }}, we would like to automate {{ repeatableTask }}.
{% if vendorNames | length == 1 %}
The most common networking vendor I work with is {{ vendorNames[0] | title }}.
{% elif vendorNames | length > 1 %}
The most common networking vendors I work with are:
{% for vendor in vendorNames %}
 - {{ vendor | title }}
{% endfor %}
{% endif %}

Step 7

Notice as we complete the form, how the output changes.

Step 8

We enter Jane for the first name and Network Engineer for the title.

Step 9

Company title is Acme Inc. We enter Change Management for Repeatable Tasks.

Part of today’s workflow will leverage a Jinja2 Template in order to format text for ServiceNow, so this small exercise will give you a better idea of how that workflow operates.



Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.