--- title: "ServiceNow Adapter Actions" slug: "servicenow-adapter-actions" description: "This is a list of actions that can be used in RapidIdentity Connect to interact with a ServiceNow adapter." tags: ["RapidIdentity ", "Connect", "Adapter", "Actions", "ServiceNow"] updated: 2022-06-03T19:55:20Z published: 2022-06-03T19:55:20Z canonical: "help.rapididentity.com/servicenow-adapter-actions" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.rapididentity.com/llms.txt > Use this file to discover all available pages before exploring further. # ServiceNow Adapter Actions ## ServiceNow Adapter Actions ### defineServiceNowConnection Define a connection to a ServiceNow Server. | Property | Value | Description | | --- | --- | --- | | url* | text, expression, variable | the Base URL of the ServiceNow web service | | username* | text, expression, variable | Username for authentication to the ServiceNow web service | | password* | password, string, expression, variable | Password for authentication to the ServiceNow web service | | options | expression, variable | A record or JavaScript object with a field for each additional option. Currently defined fields are connectTimeout and socketTime which require a numeric value from 1 to 2147483647 (0x7FFFFFFF) that represents the number of milliseconds for the timeout, and 0 representing no timeout. | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript Global.snUrl = "https://sandbox.service-now.com" Global.snUser = "admin" Global.snPwd = "admin" session = defineServiceNowConnection(Global.snUrl, Global.snUser, Global.snPwd) ``` ### deleteServiceNowRecord Deletes the record in ServiceNow. Returns a success boolean. | Property | Value | Description | | --- | --- | --- | | connection* | expression, variable | the ServiceNow connection definition | | objectType* | text, expression, variable | The ServiceNow object type | | id* | text, expression, variable | The sys_id of the ServiceNow record to delete. | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript users = getServiceNowRecords(session, "sys_user", "user_name=joh.doe, 1) if(users.length) { result = deleteServiceNowRecord(session, "sys_user", users[0][\'sys_id\']) } ``` ### getServiceNowRecord Gets a given ServiceNow Record. | Property | Value | Description | | --- | --- | --- | | connection* | expression, variable | the ServiceNow connection definition | | objectType* | text, expression, variable | The ServiceNow object type | | id* | text, expression, variable | The sys_id of the ServiceNow record. | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript user = getServiceNowRecord(session, "02826bf03710200044e0bfc8bcbe5d55") ``` ### getServiceNowRecords Get All ServiceNow Records. | Property | Value | Description | | --- | --- | --- | | connection* | expression, variable | the ServiceNow connection definition | | objectType* | text, expression, variable | The ServiceNow object type | | filter | text, expression, variable | The filter used to limit results. Can either be an encoded query as specified by ServiceNow, or a Record example object. | | limit | expression, variable | The maximum number of records to return. Defaults to all objects. | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript users = getServiceNowRecords(sessionServiceNow, "sys_user", "user_name=john.doe", 1) ``` ### openServiceNowRecordIterator Open a ServiceNow Record Iterator. | Property | Value | Description | | --- | --- | --- | | connection* | expression, variable | the ServiceNow connection definition | | objectType* | text, expression, variable | The ServiceNow object type | | filter | text, expression, variable | The filter used to limit results. Can either be an encoded query as specified by ServiceNow, or a Record example object. | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript it = openServiceNowRecordIterator(sessionServiceNow, "sys_user") forEach(user, it) { # do something with user } close(it) ``` ### saveServiceNowRecord Creates or updates the record in ServiceNow. Returns the id of the object. | Property | Value | Description | | --- | --- | --- | | connection* | expression, variable | the ServiceNow connection definition | | objectType* | text, expression, variable | The ServiceNow object type | | record* | text, expression, variable | A Record object containing the fields you want to save. If 'sys_id' is set, an update will be performed, otherwise a create will be performed. | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript userTemplate = createRecord(true) setRecordFieldValue(userTemplate, "user_name", "john.doe") setRecordFieldValue(userTemplate, "first_name", "John") setRecordFieldValue(userTemplate, "user_name", "john.doe") setRecordFieldValue(userTemplate, "user_name", "john.doe") user = saveServiceNowRecord(sessionServiceNow, "sys_user", userTemplate) ```