servicenow.servicenow.snow_record_find – Search for multiple records from ServiceNow
Note
This plugin is part of the servicenow.servicenow collection (version 1.0.3).
To install it use: ansible-galaxy collection install servicenow.servicenow.
To use it in a playbook, specify: servicenow.servicenow.snow_record_find.
Synopsis
- Gets multiple records from a specified table from ServiceNow based on a query dictionary.
Requirements
The below requirements are needed on the host that executes this module.
- python pysnow (pysnow)
Parameters
| Parameter | Choices/Defaults | Comments |
|---|---|---|
| client_id string | Client ID generated by ServiceNow. | |
| client_secret string | Client Secret associated with client id. | |
| host string | The ServiceNow hostname. This value is FQDN for ServiceNow host. If the value is not specified in the task, the value of environment variable SN_HOST will be used instead.Mutually exclusive with instance. | |
| instance string | The ServiceNow instance name, without the domain, service-now.com. If the value is not specified in the task, the value of environment variable SN_INSTANCE will be used instead. | |
| max_records integer | Default: 20 | Maximum number of records to return. |
| order_by string | Default: "-created_on" | Field to sort the results on. Can prefix with "-" or "+" to change descending or ascending sort order. |
| password string | Password for username. Required whether using Basic or OAuth authentication. If the value is not specified in the task, the value of environment variable SN_PASSWORD will be used instead. | |
| query dictionary / required | Dict to query for records. | |
| return_fields list / elements=string | Fields of the record to return in the json. By default, all fields will be returned. | |
| table string | Default: "incident" | Table to query for records. |
| username string | Name of user for connection to ServiceNow. Required whether using Basic or OAuth authentication. If the value is not specified in the task, the value of environment variable SN_USERNAME will be used instead. |
Examples
- name: Search for incident assigned to group, return specific fields
servicenow.servicenow.snow_record_find:
username: ansible_test
password: my_password
instance: dev99999
table: incident
query:
assignment_group: d625dccec0a8016700a222a0f7900d06
return_fields:
- number
- opened_at
- name: Search for incident using host instead of instance
servicenow.servicenow.snow_record_find:
username: ansible_test
password: my_password
host: dev99999.mycustom.domain.com
table: incident
query:
assignment_group: d625dccec0a8016700a222a0f7900d06
return_fields:
- number
- opened_at
- name: Using OAuth, search for incident assigned to group, return specific fields
servicenow.servicenow.snow_record_find:
username: ansible_test
password: my_password
client_id: "1234567890abcdef1234567890abcdef"
client_secret: "Password1!"
instance: dev99999
table: incident
query:
assignment_group: d625dccec0a8016700a222a0f7900d06
return_fields:
- number
- opened_at
- name: Find open standard changes with my template
servicenow.servicenow.snow_record_find:
username: ansible_test
password: my_password
instance: dev99999
table: change_request
query:
AND:
equals:
active: "True"
type: "standard"
u_change_stage: "80"
contains:
u_template: "MY-Template"
return_fields:
- sys_id
- number
- sys_created_on
- sys_updated_on
- u_template
- active
- type
- u_change_stage
- sys_created_by
- description
- short_description
Return Values
Common return values are documented here, the following are the fields unique to this module:
| Key | Returned | Description |
|---|---|---|
| record dictionary | always | The full contents of the matching ServiceNow records as a list of records. |
Authors
- Tim Rightnour (@garbled1)
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.10/collections/servicenow/servicenow/snow_record_find_module.html