Learn Working with External Data (CAD) with Interactive Flashcards

Master key concepts in Working with External Data through our interactive flashcard system. Click on each card to reveal detailed explanations and enhance your understanding.

Import Sets

Import Sets in ServiceNow are a powerful feature designed to facilitate the ingestion and transformation of data from external sources into the ServiceNow platform. They serve as a staging area where external data is temporarily stored before being mapped and transferred to target tables within the ServiceNow database.

When data is imported into ServiceNow—whether from CSV files, JDBC connections, LDAP, Excel spreadsheets, XML, or other data sources—it first lands in an Import Set table. This staging table holds the raw data exactly as it was received, allowing administrators and developers to review, cleanse, and manipulate the data before committing it to production tables.

The key components of Import Sets include:

1. **Data Sources**: These define where the external data originates from, such as a file attachment, FTP location, JDBC database connection, or REST/SOAP integrations.

2. **Import Set Tables**: These are automatically created staging tables that temporarily hold imported data. Each import operation creates records in these tables for processing.

3. **Transform Maps**: These are critical components that define how data from the Import Set table maps to fields in the target table. Transform Maps allow field-level mapping, including direct mappings, scripted transformations, and conditional logic.

4. **Transform Scripts**: These include onBefore, onAfter, and onStart scripts that enable developers to apply custom business logic during the transformation process, such as data validation, coalescing (matching existing records to prevent duplicates), and data enrichment.

5. **Scheduled Imports**: Import Sets can be automated using scheduled jobs to run at specified intervals, enabling regular data synchronization with external systems.

The import process follows a clear workflow: data is pulled from the source, loaded into the Import Set staging table, transformed using Transform Maps, and finally inserted or updated in the target table. Import Sets also provide robust error handling and logging, allowing developers to track the status of each imported row and troubleshoot any issues that arise during the transformation process. This makes them essential for enterprise data integration scenarios.

Data Sources (CSV, Excel, JDBC)

In ServiceNow, Data Sources are configurations that define external data origins used to import data into the platform. They serve as the foundational component of the Import Set framework, enabling seamless integration with external systems and files. There are three primary types of data sources commonly used:

**CSV (Comma-Separated Values):**
CSV data sources allow you to import flat-file data formatted with comma-delimited values. These files can be uploaded manually or retrieved automatically via FTP, HTTP, or file attachment. CSV imports are lightweight and ideal for simple data migrations such as user lists, asset inventories, or configuration items. ServiceNow parses each row into an import set table for transformation.

**Excel (XLS/XLSX):**
Excel data sources support Microsoft Excel file formats. Similar to CSV, Excel files can be uploaded directly or fetched from external locations. Excel imports are useful when data contains multiple sheets or requires structured formatting. ServiceNow reads the specified sheet and maps columns to fields in the import set table. This is commonly used for bulk data loads during initial implementations or periodic updates.

**JDBC (Java Database Connectivity):**
JDBC data sources enable direct connections to external relational databases such as Oracle, MySQL, SQL Server, or PostgreSQL. By configuring a JDBC connection with the appropriate driver, connection URL, credentials, and SQL query, ServiceNow can pull data directly from external database tables. JDBC sources are powerful for real-time or scheduled integrations where data resides in enterprise systems. A MID Server is typically required to facilitate secure communication between ServiceNow and on-premise databases.

**Key Workflow:**
Regardless of type, the process follows a consistent pattern: Data Source → Import Set Table → Transform Map → Target Table. The data source feeds raw data into an import set staging table, where transform maps define field mappings, coalescing rules, and scripts to populate the destination table accurately.

Data sources can be scheduled to run automatically, enabling recurring imports and ensuring data stays synchronized between ServiceNow and external systems.

Transform Maps and Field Mapping

Transform Maps and Field Mapping are essential components in ServiceNow for importing and integrating external data into the platform. They serve as the bridge between raw imported data and the target tables where the data ultimately resides.

**Transform Maps** define the relationship between an import set table (staging table) and a target table in ServiceNow. When external data is imported via CSV, JDBC, LDAP, or other data sources, it first lands in an import set table. The Transform Map then dictates how this staged data should be processed and moved into the appropriate production table. A single import set can have multiple Transform Maps, allowing data from one source to populate multiple target tables. Transform Maps also support run order, enabling sequential processing when multiple maps exist.

**Field Mapping** is the core component within a Transform Map that defines how individual columns from the import set table map to specific fields in the target table. There are several types of field mappings:

1. **Direct Mapping** - Maps a source field directly to a target field.
2. **Auto Mapping** - ServiceNow automatically matches source and target fields based on matching field names.
3. **Mapping by Script** - Uses server-side JavaScript to transform or manipulate data before inserting it into the target field.
4. **Choice Action** - Determines how to handle values that don't match existing choice list options (reject, create, or ignore).

**Coalesce Fields** are special field mappings used to determine whether an incoming record should create a new record or update an existing one. If a matching value is found in the coalesced field, the record is updated rather than duplicated.

**Transform Scripts** (onBefore, onAfter, onStart, onComplete) provide additional control over the transformation process, allowing developers to execute custom logic at various stages.

Together, Transform Maps and Field Mapping ensure data integrity, prevent duplication, and enable complex data transformations during the import process, making them critical for any ServiceNow integration strategy.

Transform Scripts

Transform Scripts in ServiceNow are powerful scripting mechanisms used during the data import process to manipulate and control how data is transformed from a staging table (import set table) into a target table. They are a critical component of the Import Set framework, which is used to bring external data into ServiceNow.

Transform Scripts run during the execution of a Transform Map and allow developers to apply custom logic at various stages of the transformation process. They provide granular control over how each record or the entire dataset is processed.

There are two primary types of Transform Scripts based on when they execute:

1. **onStart** – Runs once before any records are transformed. This is useful for initializing variables, setting up counters, or performing pre-processing tasks like clearing existing data before new data is imported.

2. **onComplete** – Runs once after all records have been transformed. This is commonly used for cleanup tasks, logging summaries, sending notifications, or triggering follow-up processes.

3. **onBefore** – Runs before each individual record is transformed. Developers can use this to validate data, set default values, skip records based on conditions, or manipulate source values before they are mapped to the target.

4. **onAfter** – Runs after each individual record is transformed. This is useful for creating related records, updating additional fields, or performing post-insert logic on the target record.

5. **onForeignInsert** – Runs when a reference field requires the creation of a new record in a referenced table.

Within Transform Scripts, developers have access to key objects such as `source` (the import set row), `target` (the target table record), `map` (the transform map), `log` (for logging), and `action` (to determine insert/update behavior or skip records using `ignore`).

Transform Scripts are essential for handling complex transformation requirements that cannot be achieved through simple field mapping alone, enabling developers to integrate external data seamlessly into ServiceNow while maintaining data integrity and business logic compliance.

Coalesce Rules

Coalesce Rules in ServiceNow are a critical concept when working with external data, particularly during data import operations using Import Sets and Transform Maps. Coalesce is essentially a mechanism that determines whether an incoming record should create a new record in the target table or update an existing one.

When importing data from external sources (such as CSV files, JDBC connections, LDAP, REST APIs, or other integrations), ServiceNow uses Transform Maps to map source fields to target table fields. Within these Transform Maps, you can designate one or more fields as 'coalesce' fields by checking the Coalesce checkbox on the field mapping.

Here is how coalesce works:

1. **Matching Logic**: When a record is being transformed, ServiceNow checks the coalesce field(s) to find a matching record in the target table. If a match is found, the existing record is updated. If no match is found, a new record is created.

2. **Single vs. Multiple Coalesce Fields**: You can set coalesce on a single field (e.g., email address) or multiple fields. When multiple fields are coalesced, ALL coalesced fields must match for an existing record to be identified (AND logic).

3. **Use Cases**: Common coalesce fields include unique identifiers like employee ID, email address, asset tag, or serial number — fields that uniquely identify a record.

4. **No Coalesce Set**: If no coalesce field is defined, every imported record will create a new record in the target table, potentially resulting in duplicates.

5. **Conditional Coalesce**: ServiceNow also supports more advanced scenarios where you can use scripts in Transform Map scripts (onBefore, onAfter) to implement custom coalesce logic.

6. **Best Practices**: Always define at least one coalesce field to prevent duplicate records. Choose fields that are truly unique and consistently populated in both the source and target data.

Coalesce rules are fundamental to maintaining data integrity when integrating external data into ServiceNow, ensuring clean, accurate, and duplicate-free records in your instance.

Outbound REST Messages

Outbound REST Messages in ServiceNow are a powerful mechanism that allows a ServiceNow instance to communicate with external systems and APIs by sending HTTP requests. As a Certified Application Developer, understanding Outbound REST Messages is essential for integrating ServiceNow with third-party services and working with external data.

An Outbound REST Message is a configuration record that defines the connection details for an external REST API endpoint. It includes the endpoint URL, authentication method, and one or more HTTP methods (GET, POST, PUT, PATCH, DELETE) that can be invoked against the external service.

Key components of Outbound REST Messages include:

1. **Endpoint**: The base URL of the external REST API you want to communicate with. Variable substitution is supported using the ${variable} syntax for dynamic URLs.

2. **Authentication**: Supports multiple authentication types including Basic, OAuth 2.0, Mutual Authentication, and API Key-based authentication profiles.

3. **HTTP Methods**: Each REST Message can contain multiple HTTP method records, each representing a specific operation (e.g., GET to retrieve data, POST to create records).

4. **HTTP Headers and Query Parameters**: Custom headers and parameters can be configured for each HTTP method to meet the external API's requirements.

5. **Request Body**: For POST, PUT, and PATCH methods, you can define a request body template with variable substitution.

Outbound REST Messages can be invoked through scripting using the RESTMessageV2 API. In a script, you instantiate the message, set variable values, and call the execute() method to send the request. The response can then be parsed to extract relevant data.

Example script usage:
- Create a RESTMessageV2 object referencing the REST Message record
- Set required variables using setStringParameterNoEscape()
- Execute the request and capture the response
- Parse the response body, status code, and headers

For testing purposes, ServiceNow provides a built-in REST Message testing tool that allows developers to preview and send requests directly from the configuration form. This feature helps validate configurations before implementing them in business logic or automation workflows.

Scripted REST APIs

Scripted REST APIs in ServiceNow provide a powerful framework that allows developers to create custom RESTful web services directly within the platform. Unlike the standard REST API that exposes existing tables and records, Scripted REST APIs give developers full control over the request handling, response formatting, and business logic execution.

A Scripted REST API consists of three main components: the API definition, API resources, and the scripted logic. The API definition establishes the base path and namespace for your custom endpoint. Resources define the specific HTTP methods (GET, POST, PUT, PATCH, DELETE) and relative paths that clients can call. The scripted logic, written in server-side JavaScript, processes incoming requests and constructs appropriate responses.

When creating a Scripted REST API, developers navigate to System Web Services > Scripted REST APIs and define the API name, API ID, and namespace. Resources are then added under the API, where each resource specifies the HTTP method, relative path (which can include path parameters like /{id}), and the server-side script that handles the request.

Within the resource script, developers have access to the request object (containing headers, query parameters, path parameters, and request body) and the response object (used to set status codes, headers, and the response body). This allows for sophisticated data transformation, validation, authentication checks, and integration with external systems.

Key benefits include the ability to create versioned APIs, implement custom authentication and authorization, format responses in any structure (not limited to ServiceNow's default table API format), aggregate data from multiple sources, and enforce business rules before returning data.

Scripted REST APIs also support content negotiation, allowing developers to return data in JSON, XML, or other formats based on the Accept header. They integrate seamlessly with ServiceNow's access control mechanisms and can leverage existing Script Includes and GlideRecord queries.

This capability is essential for the Certified Application Developer exam, as it demonstrates proficiency in building custom integrations and exposing ServiceNow functionality to external consumers in a controlled, secure manner.

REST API Explorer

The REST API Explorer in ServiceNow is a powerful built-in tool that allows developers to discover, test, and interact with both inbound and outbound REST APIs directly within the ServiceNow platform. It serves as an interactive documentation and testing environment, making it significantly easier to work with external data and integrate ServiceNow with third-party systems.

Accessed through the System Web Services > REST API Explorer module, this tool provides a user-friendly interface where developers can explore available REST APIs, including both ServiceNow's standard Table API, Aggregate API, Import Set API, and any custom Scripted REST APIs that have been created.

Key features of the REST API Explorer include:

1. **API Discovery**: It lists all available REST API endpoints, their methods (GET, POST, PUT, PATCH, DELETE), and the parameters they accept, allowing developers to quickly understand the available operations.

2. **Interactive Testing**: Developers can construct and send REST API requests directly from the explorer. They can set query parameters, request headers, and request body content, then execute the call and view the response in real-time.

3. **Code Generation**: One of its most valuable features is the ability to automatically generate code snippets in multiple languages, including JavaScript (for use in ServiceNow scripts), Python, Ruby, Perl, and cURL commands. This accelerates development by providing ready-to-use code templates.

4. **Authentication Configuration**: The explorer supports various authentication methods including basic authentication and OAuth, allowing developers to test secured endpoints properly.

5. **Response Visualization**: It displays response status codes, headers, and body content in a formatted view, making it easy to analyze the returned data.

For ServiceNow Application Developers, the REST API Explorer is essential when building integrations that consume external REST services or when exposing ServiceNow data to external systems. It streamlines the development process by reducing trial and error, enabling rapid prototyping, and providing accurate code samples that can be incorporated directly into Business Rules, Script Includes, Scheduled Jobs, or Scripted REST APIs.

Integration Authentication Methods

Integration Authentication Methods in ServiceNow are critical mechanisms used to securely connect and exchange data with external systems. As a Certified Application Developer, understanding these methods is essential for building robust integrations.

**1. Basic Authentication:** The simplest method where a username and password are sent with each request, typically encoded in Base64. While easy to implement, it should always be used over HTTPS to prevent credential exposure. ServiceNow supports this for both inbound and outbound integrations.

**2. OAuth 2.0:** A token-based authentication framework that allows secure delegated access without sharing credentials. ServiceNow supports OAuth as both a provider and consumer. It involves obtaining access tokens through authorization grants, which are then used to authenticate API requests. OAuth 2.0 supports multiple grant types including Authorization Code, Client Credentials, and Resource Owner Password Credentials.

**3. Mutual Authentication (mTLS):** Both the client and server present certificates to verify each other's identity. This provides a higher level of security and is commonly used in enterprise-to-enterprise integrations where strict security compliance is required.

**4. API Key Authentication:** A simple method where a unique key is passed in the request header or URL parameters. ServiceNow can consume APIs requiring API keys through REST Message configurations.

**5. LDAP Authentication:** Used primarily for integrating with directory services for user authentication and data synchronization.

**6. SAML/SSO:** Security Assertion Markup Language enables Single Sign-On capabilities, allowing users to authenticate once and access multiple systems including ServiceNow.

**7. JWT (JSON Web Tokens):** A compact, URL-safe token format used for securely transmitting claims between parties, often used in conjunction with OAuth 2.0.

When configuring integrations, developers define authentication profiles in Connection and Credential Aliases, which decouple credentials from integration logic. This promotes reusability and security. The choice of authentication method depends on the external system's requirements, security policies, and the nature of the integration. Best practices include using OAuth 2.0 where possible, always encrypting communications with HTTPS, and leveraging credential stores to protect sensitive information.

Import Error Handling

Import Error Handling in ServiceNow is a critical mechanism that ensures data integrity and reliability when importing external data into the platform through Import Sets and Transform Maps. When importing data from external sources such as CSV files, JDBC connections, LDAP, REST, or SOAP integrations, errors can occur at various stages, and proper handling is essential.

**Types of Import Errors:**
1. **Data Type Mismatches** – When source data doesn't match the target field type (e.g., importing text into an integer field).
2. **Mandatory Field Violations** – When required fields in the target table are left empty.
3. **Reference Lookup Failures** – When a referenced record cannot be found during transformation.
4. **Script Errors** – When Transform Map scripts (onBefore, onAfter, onStart, onComplete) encounter runtime exceptions.
5. **Duplicate Record Conflicts** – When coalesce fields identify conflicts with existing records.

**Error Handling Mechanisms:**
- **Transform Error Handler**: ServiceNow provides built-in error handling in Transform Maps. You can configure what happens when an error occurs — options include stopping the import, skipping the record, or logging the error and continuing.
- **Import Log**: The Import Set table maintains a status field for each row (inserted, updated, error, ignored), allowing administrators to review problematic records.
- **onError Script**: Transform Maps support an onError script that executes when a row-level error occurs, enabling custom logic such as notifications or alternative processing.
- **Error Field Mapping**: You can map error details to specific fields for auditing purposes.

**Best Practices:**
1. Always test imports in a sub-production environment first.
2. Use data validation scripts in onBefore transform scripts to catch issues proactively.
3. Implement robust coalesce strategies to prevent duplicate records.
4. Monitor the Import Set Run table to track overall import health.
5. Set up notifications for import failures to ensure timely resolution.
6. Use try-catch blocks in transform scripts to gracefully handle exceptions.

Proper import error handling minimizes data corruption, ensures accountability through logging, and maintains the overall quality of data flowing into ServiceNow from external systems.

More Working with External Data questions
493 questions (total)