---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# NowTableService class - iOS

# NowTableService class - iOS {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 68 minutes to read

The NowTableService class provides functions that enable you to
perform create, read, update, and delete operations on records of existing ServiceNow tables.
{#NowTableServiceiOSAPI__table_vx2_klw_5pb__entry__3}

| Name | Type | Description |
|-|-|-|
| configuration | [NowServiceConfiguration](https://servicenow-prod.fluidtopics.net/A6W2zQ0fOO_VQ9lbo3VKwQ#NowServiceConfigurationiOSStruct "The NowServiceConfiguration structure defines configuration information for a feature service.") | Configuration settings provided when the service was initialized. |
[Table 1. Properties]

{#NowTableServiceiOSAPI__table_vx2_klw_5pb}

## NowTableService - create\<Model: SysIdentifiableModel\>(_ model: Model, in tableName: String, coder: Coder, writeOptions: FieldWriteOptions, configuration: FetchConfiguration) async throws {#ariaid-title2}

Inserts the specified Codable model into the specified table.
In order to create a new record by model, the model must conform to the `SysIdentifiableModel` protocol. Each table will typically have its own model.

The model's sys_Id parameter is ignored during creation as the sysId is generated by the ServiceNow platform. The ServiceNow platform generated sys_Id is returned in the completion handler's `Result` model.
{#NTblServ-create-async_S_S_S_O_O__table_tqk_gsk_spb__entry__3}

| Name | Type | Description |
|-|-|-|
| model | SysIdentifiableModel | Model definition of the fields to insert into the table. |
| in tableName | String | Name of the table in which to write the records, such as incident. |
| coder | Coder | Optional. `Coder` to use to encode or decode data sent to and received from the ServiceNow instance. Possible values: * default: The default encoders format dates using the `yyy-MM-dd HH:mm:ss` format by using the device `Locale` and `TimeZone`. * custom(JSONEncoder, JSONDecoder): Use `custom` coders to have more fine-grained control on JSON decoding/encoding. Only use this enumeration to supply your own `JSONEncoder` and `JSONDecoder`, for example when using special date formats, time zones, or locales. let myEncoder = JSONEncoder() myEncoder.dateFormat = ... let myDecoder = JSONDecoder() myDecoder.dateFormat = ... let coder: Coder = .custom(myEncoder, myDecoder) {#NTblServ-create-async_S_S_S_O_O__ul_nx3_wrd_sqb} Default: .default |
| writeOptions | [FieldWriteOptions](https://servicenow-prod.fluidtopics.net/QnzQhyqUjnNQnz_YHU0hhw#FieldWriteOptionsiOSStruct "The FieldWriteOptions class provides functions that set the options for updating or creating fields in a record on a ServiceNow instance.") | Optional. Configuration options to apply to the data being written to the record. Default: nil |
| configuration | [FetchConfiguration](https://servicenow-prod.fluidtopics.net/l6lFs6UaAdGVvttsDa2ucw#FetchConfigiOSStructure "The FetchConfiguration structure provides the ability to define the configuration for fetching records from your ServiceNow instance.") | Optional. Configuration to apply to the retrieved records, including filters that define the records to return, pagination page size limit, which fields to retrieve, and what to include in the fields. Default: nil - All records returned. |
[Table 2. Parameters]

{#NTblServ-create-async_S_S_S_O_O__table_tqk_gsk_spb} {#NTblServ-create-async_S_S_S_O_O__table_uqk_gsk_spb__entry__2}

| Type | Description |
|-|-|
| Model | Returned when the method is successful. Codable model that was inserted in the specified table, including the sys_Id. Use this sys_id to reference this record in future method calls. |
| NowDataError | Thrown when the method fails. * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-create-async_S_S_S_O_O__NowDataErroriOS-ul-enum} |
[Table 3. Returns]

{#NTblServ-create-async_S_S_S_O_O__table_uqk_gsk_spb}  
The following code example shows how to call this method.

    struct User: SysIdentifiableModel {
        var sysId: String = ""
        var name: String
    }

    let service: NowTableService = ...
    let user = User(name: "Ash Williams")
    do {
        let result = try await service.create(user, in: "sys_user")
    } catch {
        ...
    }

## NowTableService - create\<Model: SysIdentifiableModel\>(_ model: Model, in tableName:
String, coder: Coder, writeOptions: FieldWriteOptions, configuration: FetchConfiguration,
completion: @escaping (Result\<Model, NowDataError\>)) {#ariaid-title3}

Inserts the specified Codable model into the specified table and then executes the
completion handler.
In order to create a new record by model, the model must conform to the `SysIdentifiableModel` protocol. Each table will typically have its own model. For example:

    struct User: SysIdentifiableModel {
      var sysId: String = ""
      var name: String
    }

    let service: NowTableService = ...
    let user = User(name: "Ash Williams")
    service.create(Incident(fields: fields), in: tableName, writeOptions: writeOptions, configuration: fetchConfiguration) { [weak self] result in
      switch result {
      case .success(let newUser):
        /// 'newUser' contains the platform assigned 'sys_id', use in subsequent 'update' or 'delete' calls.
      case .failure(let error):
          ...
      }
    }

The model's sys_Id parameter is ignored during creation as the
sysId is generated by the ServiceNow platform.
The ServiceNow platform generated sys_Id is
returned in the completion handler's `Result` model.
{#NTblServ-create_S_S_S_O_O_O__table_tqk_gsk_spb__entry__3}

| Name | Type | Description |
|-|-|-|
| model | SysIdentifiableModel | Model definition of the fields to insert into the table. |
| in tableName | String | Name of the table in which to write the records, such as incident. |
| coder | Coder | Optional. `Coder` to use to encode or decode data sent to and received from the ServiceNow instance. Possible values: * default: The default encoders format dates using the `yyy-MM-dd HH:mm:ss` format by using the device `Locale` and `TimeZone`. * custom(JSONEncoder, JSONDecoder): Use `custom` coders to have more fine-grained control on JSON decoding/encoding. Only use this enumeration to supply your own `JSONEncoder` and `JSONDecoder`, for example when using special date formats, time zones, or locales. let myEncoder = JSONEncoder() myEncoder.dateFormat = ... let myDecoder = JSONDecoder() myDecoder.dateFormat = ... let coder: Coder = .custom(myEncoder, myDecoder) {#NTblServ-create_S_S_S_O_O_O__ul_nx3_wrd_sqb} Default: .default |
| writeOptions | [FieldWriteOptions](https://servicenow-prod.fluidtopics.net/QnzQhyqUjnNQnz_YHU0hhw#FieldWriteOptionsiOSStruct "The FieldWriteOptions class provides functions that set the options for updating or creating fields in a record on a ServiceNow instance.") | Optional. Configuration options to apply to the data being written to the record. Default: nil |
| configuration | [FetchConfiguration](https://servicenow-prod.fluidtopics.net/l6lFs6UaAdGVvttsDa2ucw#FetchConfigiOSStructure "The FetchConfiguration structure provides the ability to define the configuration for fetching records from your ServiceNow instance.") | Optional. Configuration to apply to the retrieved records, including filters that define the records to return, pagination page size limit, which fields to retrieve, and what to include in the fields. Default: nil - All records returned. |
| completion | @escaping (Result\<Model, NowDataError\>) | Completion handler to execute after creating the specified decodable model(s). Return values for the completion handler: * Success: Model - Data for the created model type. * Failure: NowDataError * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-create_S_S_S_O_O_O__NowDataErroriOS-ul-enum} {#NTblServ-create_S_S_S_O_O_O__ul_dpx_jvk_spb} |
[Table 4. Parameters]

{#NTblServ-create_S_S_S_O_O_O__table_tqk_gsk_spb} {#NTblServ-create_S_S_S_O_O_O__table_uqk_gsk_spb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 5. Returns]

{#NTblServ-create_S_S_S_O_O_O__table_uqk_gsk_spb}  
<br />

    struct User: SysIdentifiableModel {
      var sysId: String = ""
      var name: String
    }

    let service: NowTableService = ...
    let user = User(name: "Ash Williams")
    service.create(Incident(fields: fields), in: tableName, writeOptions: writeOptions, configuration: fetchConfiguration) { [weak self] result in
      switch result {
      case .success(let newUser):
        /// 'newUser' contains the platform assigned 'sys_id' to use in subsequent update or delete calls.
      case .failure(let error):
       ...
      }
    }

## NowTableService - create\<Model: SysIdentifiableModel\>(model: Model, in tableName:
String, path: String = Constants.resultPath, coder: Coder = .default, writeOptions:
FieldWriteOptions? = nil, configuration: FetchConfiguration = nil) {#ariaid-title4}

Inserts one Codable model into the specified table.
Note:  
This method has been deprecated. You should use the async/await implementation of the method instead.  
In order to create a new record by model, the model must conform to the `SysIdentifiableModel` protocol. Each table will typically have its own model. For example:

    struct User: SysIdentifiableModel {
      var sysId: String = ""
      var name: String
    }

    let service: NowTableService = ...
    let user = User(name: "Ash Williams")
    service.create(Incident(fields: fields), in: tableName, writeOptions: writeOptions, configuration: fetchConfiguration) { [weak self] result in
      switch result {
      case .success(let newUser):
        /// 'newUser' contains the platform assigned 'sys_id', use in subsequent 'update' or 'delete' calls.
      case .failure(let error):
          ...
      }
    }

Note:  
The model's sys_Id parameter is ignored during creation. The sysId is assigned by the ServiceNow platform. The ServiceNow platform generated sys_Id is returned in the publisher's `receiveValue` callback model.
{#NTblServ-create_S_S_S_S_O_O__table_pnc_xkk_spb__entry__3}

| Name | Type | Description |
|-|-|-|
| model | SysIdentifiableModel | `SysIdentifiableModel` model to insert into the table. |
| in tableName | String | Name of the table in which to write the records, such as incident. |
| path | String | Optional. Dot separated path for the nested type. For example, `result` or `foo.bar.baz` for deeper nesting. Default: `Constants.resultPath` |
| coder | Coder | Optional. `Coder` to use to encode or decode data sent to and received from the ServiceNow instance. Possible values: * default: The default encoders format dates using the `yyy-MM-dd HH:mm:ss` format by using the device `Locale` and `TimeZone`. * custom(JSONEncoder, JSONDecoder): Use `custom` coders to have more fine-grained control on JSON decoding/encoding. Only use this enumeration to supply your own `JSONEncoder` and `JSONDecoder`, for example when using special date formats, time zones, or locales. let myEncoder = JSONEncoder() myEncoder.dateFormat = ... let myDecoder = JSONDecoder() myDecoder.dateFormat = ... let coder: Coder = .custom(myEncoder, myDecoder) {#NTblServ-create_S_S_S_S_O_O__ul_nx3_wrd_sqb} Default: .default |
| writeOptions | [FieldWriteOptions](https://servicenow-prod.fluidtopics.net/QnzQhyqUjnNQnz_YHU0hhw#FieldWriteOptionsiOSStruct "The FieldWriteOptions class provides functions that set the options for updating or creating fields in a record on a ServiceNow instance.") | Optional. Configuration options to apply to the data being written to the record. Default: nil |
| configuration | [FetchConfiguration](https://servicenow-prod.fluidtopics.net/l6lFs6UaAdGVvttsDa2ucw#FetchConfigiOSStructure "The FetchConfiguration structure provides the ability to define the configuration for fetching records from your ServiceNow instance.") | Optional. Configuration to apply to the retrieved records, including filters that define the records to return, pagination page size limit, which fields to retrieve, and what to include in the fields. Default: nil - All records returned. |
[Table 6. Parameters]

{#NTblServ-create_S_S_S_S_O_O__table_pnc_xkk_spb} {#NTblServ-create_S_S_S_S_O_O__table_qnc_xkk_spb__entry__2}

| Type | Description |
|-|-|
| AnyPublisher\<Model,NowDataError\> | Success: Codable model that was inserted in the specified table, including sys_Id. Use this sys_id to reference this record in future method calls. Failure: NowDataError @escaping (Result\<Model, NowDataError\>) |
[Table 7. Returns]

{#NTblServ-create_S_S_S_S_O_O__table_qnc_xkk_spb}  
Shows how to insert a single record into the User \[sys_user\] table.

    struct User: SysIdentifiableModel {
      var sysId: String = ""
      var name: String
    }

    let service: NowTableService = ...
    let user = User(name: "Ash Williams")
    let publisher: AnyPublisher<User, NowDataError> = service.create(user, in: "sys_user")
    publisher
      .subscribe(on: DispatchQueue.global())
      .receive(on: DispatchQueue.main)
      .sink { [weak self] completion in
        ...
      } receiveValue: { [weak self] newUser in
          /// 'newUser' contains the ServiceNow platform assigned 'sys_id' to use in subsequent update and delete calls.
         ...
      }
      .store(in: &subscriptions)

## NowTableService - createRecord(with fields: \[FieldName: FieldValue\], in tableName: String, writeOptions: FieldWriteOptions? = nil, configuration: FieldReadConfiguration? = nil) async throws {#ariaid-title5}

Inserts a record in the specified table that contains the specified fields.
The publisher emits data that you can decode into a custom [Codable model](https://developer.apple.com/documentation/foundation/archives_and_serialization/encoding_and_decoding_custom_types), or you can also use the [NowTableService - paginator\<Model: Decodable\>(from tableName: String, path: String = Constants.resultPath, coder: Coder = .default, configuration: FetchConfiguration? = nil)](https://servicenow-prod.fluidtopics.net/Mg9nOO4u3WPRvIqz4t9SUw#NTblServ-paginator_S_S_S_O "Creates a paginator that enables the iteration of pages of decoded model(s) that handle nesting.") function. Alternatively, you can use the convenience function convertToRecords() to transform data into a NowRecord object. The following shows how to convert a publisher to emit NowRecords:

    let dataPublisher: AnyPublisher<Data, NowDataError> = ...
    let recordsPublisher: AnyPublisher<[NowRecord], NowDataError> = myPublisher.convertToRecords()

Note:  
All fields within a record may not be available for update. For example, fields that have a prefix of `sys_` are typically system parameters that are automatically generated and cannot be updated. Fields that are not specified and not auto-generated by the system are set to the associated data type's null value.
{#NTblServ-createRecord-async_S_O_O__table_lww_l4j_ppb__entry__3}

| Name | Type | Description |
|-|-|-|
| with fields | \[FieldName: FieldValue\] | Name-value pairs of the fields to include in the record. |
| in tableName | String | Name of the table in which to write the records, such as incident. |
| writeOptions | [FieldWriteOptions](https://servicenow-prod.fluidtopics.net/QnzQhyqUjnNQnz_YHU0hhw#FieldWriteOptionsiOSStruct "The FieldWriteOptions class provides functions that set the options for updating or creating fields in a record on a ServiceNow instance.") | Optional. Configuration options to apply to the data being written to the record. Default: nil |
| configuration | [FetchConfiguration](https://servicenow-prod.fluidtopics.net/l6lFs6UaAdGVvttsDa2ucw#FetchConfigiOSStructure "The FetchConfiguration structure provides the ability to define the configuration for fetching records from your ServiceNow instance.") | Optional. Configuration to apply to the retrieved records, including filters that define the records to return, pagination page size limit, which fields to retrieve, and what to include in the fields. Default: nil - All records returned. |
[Table 8. Parameters]

{#NTblServ-createRecord-async_S_O_O__table_lww_l4j_ppb} {#NTblServ-createRecord-async_S_O_O__table_mww_l4j_ppb__entry__2}

| Type | Description |
|-|-|
| Data | Returned when the method is successful. Data object containing the new record. |
| NowDataError | Thrown when the method fails. * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-createRecord-async_S_O_O__NowDataErroriOS-ul-enum} |
[Table 9. Returns]

{#NTblServ-createRecord-async_S_O_O__table_mww_l4j_ppb}  
The following code examples shows how to call this method.

    do {
        let dataResult: Data = try await tableService.createRecord(with: fields, in: tableName, writeOptions: writeOptions, configuration: configuration)
        let recordResult: NowRecord = dataResult.convertToRecord()
    } catch {
        print("Record creation failed with NowDataError: \(error)")
    }

## NowTableService - createRecord(with fields: \[FieldName: FieldValue\], in tableName: String,
writeOptions: FieldWriteOptions, configuration: FieldReadConfiguration, completion: @escaping
(Result\<Data, NowDataError\>) {#ariaid-title6}

Inserts the specified record in the specified table and then executes the
completion handler after the record is saved.
If needed, you can decode the return results into a custom Codable model or you can use the [NowTableService - paginator\<Model: Decodable\>(from tableName: String, path: String = Constants.resultPath, coder: Coder = .default, configuration: FetchConfiguration? = nil)](https://servicenow-prod.fluidtopics.net/Mg9nOO4u3WPRvIqz4t9SUw#NTblServ-paginator_S_S_S_O "Creates a paginator that enables the iteration of pages of decoded model(s) that handle nesting.") function instead. Alternatively, you can use the convenience function convertToRecords() to transform data into a NowRecord object. The following shows how to convert a publisher to emit NowRecords:

    let dataPublisher: AnyPublisher<Data, NowDataError> = ...
    let recordsPublisher: AnyPublisher<[NowRecord], NowDataError> = myResult.convertToRecords()

Note:  
All fields within a record may not be available for update. For example, fields that have a prefix of `sys_` are typically system parameters that are automatically generated and cannot be updated. Fields that are not specified and not auto-generated by the system are set to the associated data type's null value.
{#NTblServ-createRecord_S_O_O_O__table_vk3_yqj_ppb__entry__3}

| Name | Type | Description |
|-|-|-|
| with fields | \[FieldName: FieldValue\] | Name-value pairs of the fields to include in the record. |
| in tableName | String | Name of the table in which to write the records, such as incident. |
| writeOptions | [FieldWriteOptions](https://servicenow-prod.fluidtopics.net/QnzQhyqUjnNQnz_YHU0hhw#FieldWriteOptionsiOSStruct "The FieldWriteOptions class provides functions that set the options for updating or creating fields in a record on a ServiceNow instance.") | Optional. Configuration options to apply to the data being written to the record. Default: nil |
| configuration | [FieldReadConfiguration](https://servicenow-prod.fluidtopics.net/Re~2rn0s~55vWcgvBUKh5g#FieldReadConfigurationiOSStruct "The FieldReadConfiguration structure enables you to configure which fields to fetch from a ServiceNow instance table and in which format.") | Optional. Configuration options that specify which fields to return and what to include in the fields. Default: nil |
| completion | @escaping (Result\<Data, NowDataError\>) | Completion handler to execute after the records are retrieved. Return values: * Success: Data - Requested records * Error: NowDataError * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-createRecord_S_O_O_O__NowDataErroriOS-ul-enum} {#NTblServ-createRecord_S_O_O_O__ul_uzx_thj_ppb} |
[Table 10. Parameters]

{#NTblServ-createRecord_S_O_O_O__table_vk3_yqj_ppb} {#NTblServ-createRecord_S_O_O_O__table_wk3_yqj_ppb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 11. Returns]

{#NTblServ-createRecord_S_O_O_O__table_wk3_yqj_ppb}  
The following code example shows how to call this function.

    let fields = ["short_description" : "test description"]
    let writeOptions: FieldWriteOptions = [.suppressAutoSysField, .treatInputValuesAsDisplayValues]
    let readConfiguration = FieldReadConfiguration(includeFields: ["number", "short_description"])

    tableService.createRecord(with: fields, in: tableName, writeOptions: writeOptions, configuration: readConfiguration) { [weak self] result in
      switch result {
        case .success(let dataResult):
          let recordResult: NowRecord = dataResult.convertToRecord()
        case .failure(let error):
           print("Record creation failed with NowDataError: \(error)")
      }
    }

## NowTableService - createRecord(with fields: \[FieldName: FieldValue\], in tableName: String,
writeOptions: FieldWriteOptions? = nil, configuration: FieldReadConfiguration? = nil) {#ariaid-title7}

Inserts a record in the specified table that contains the specified fields.
Note:  
This method has been deprecated. You should use the async/await implementation of the method instead.  
The publisher emits data that you can decode into a custom [Codable model](https://developer.apple.com/documentation/foundation/archives_and_serialization/encoding_and_decoding_custom_types), or you can also use the [NowTableService - paginator\<Model: Decodable\>(from tableName: String, path: String = Constants.resultPath, coder: Coder = .default, configuration: FetchConfiguration? = nil)](https://servicenow-prod.fluidtopics.net/Mg9nOO4u3WPRvIqz4t9SUw#NTblServ-paginator_S_S_S_O "Creates a paginator that enables the iteration of pages of decoded model(s) that handle nesting.") function. Alternatively, you can use the convenience function convertToRecords() to transform data into a NowRecord object. The following shows how to convert a publisher to emit NowRecords:

    let dataPublisher: AnyPublisher<Data, NowDataError> = ...
    let recordsPublisher: AnyPublisher<[NowRecord], NowDataError> = myPublisher.convertToRecords()

Note:  
All fields within a record may not be available for update. For example, fields that have a prefix of `sys_` are typically system parameters that are automatically generated and cannot be updated. Fields that are not specified and not auto-generated by the system are set to the associated data type's null value.
{#NTblServ-createRecord_S_O_O__table_lww_l4j_ppb__entry__3}

| Name | Type | Description |
|-|-|-|
| with fields | \[FieldName: FieldValue\] | Name-value pairs of the fields to include in the record. |
| in tableName | String | Name of the table in which to write the records, such as incident. |
| writeOptions | [FieldWriteOptions](https://servicenow-prod.fluidtopics.net/QnzQhyqUjnNQnz_YHU0hhw#FieldWriteOptionsiOSStruct "The FieldWriteOptions class provides functions that set the options for updating or creating fields in a record on a ServiceNow instance.") | Optional. Configuration options to apply to the data being written to the record. Default: nil |
| configuration | [FetchConfiguration](https://servicenow-prod.fluidtopics.net/l6lFs6UaAdGVvttsDa2ucw#FetchConfigiOSStructure "The FetchConfiguration structure provides the ability to define the configuration for fetching records from your ServiceNow instance.") | Optional. Configuration to apply to the retrieved records, including filters that define the records to return, pagination page size limit, which fields to retrieve, and what to include in the fields. Default: nil - All records returned. |
[Table 12. Parameters]

{#NTblServ-createRecord_S_O_O__table_lww_l4j_ppb} {#NTblServ-createRecord_S_O_O__table_mww_l4j_ppb__entry__2}

| Type | Description |
|-|-|
| AnyPublisher\<Data, NowDataError\> | Success: Data object containing the updated record. Failure: NowDataError * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-createRecord_S_O_O__NowDataErroriOS-ul-enum} |
[Table 13. Returns]

{#NTblServ-createRecord_S_O_O__table_mww_l4j_ppb}  
This example shows how to create a function that inserts a record in the specified table,
with the specified fields. The output of the call is a ByteArray which allows you to convert
the data into any model that you want.

    tableService.createRecord(with: fields, in: tableName, writeOptions: writeOptions, configuration: readConfiguration)
        .subscribe(on: DispatchQueue.global())
        .receive(on: DispatchQueue.main)
        .convertToRecord()
        .sink { completion in
            if case let .failure(error) = completion {
                print("Record creation failed with NowDataError: \(error)")
            }
        } receiveValue: { record in
            print("Created NowRecord: \(record)")
        }
        .store(in: &subscriptions)

## NowTableService - delete(_ model: Model, from tableName: String) async throws {#ariaid-title8}

Deletes the specified Codable model from the specified table.
{#NTblServ-delete-async_S_S__table_qvl_lzk_spb__entry__3}

| Name | Type | Description |
|-|-|-|
| model | Model | `SysIdentifiableModel` to delete from the table. It should contain the sys_id of the record to delete. |
| from tableName | String | Name of the table from which to delete the information, such as incident. |
[Table 14. Parameters]

{#NTblServ-delete-async_S_S__table_qvl_lzk_spb} {#NTblServ-delete-async_S_S__table_rvl_lzk_spb__entry__2}

| Type | Description |
|-|-|
| None | Nothing returned when the method is successful. |
| NowDataError | Thrown when the method fails. * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-delete-async_S_S__NowDataErroriOS-ul-enum} |
[Table 15. Returns]

{#NTblServ-delete-async_S_S__table_rvl_lzk_spb}  
The following code examples shows how to call this method.

    do { 
        try await tableService.delete(model, from: tableName)
        print("Deletion successful.")
    } catch {
        print("Deletion failed with NowDataError: \(error)")
    }

## NowTableService - delete(_ model: Model, from tableName: String, completion: @escaping
(Result\<Void, NowDataError\>)) {#ariaid-title9}

Deletes the specified Codable model from the specified table and then executes the
appropriate completion handler.
{#NTblServ-delete_S_S_O__table_zss_k1l_spb__entry__3}

| Name | Type | Description |
|-|-|-|
| model | Model | `SysIdentifiableModel` to delete from the table. It should contain the sys_id of the record to delete. |
| from tableName | String | Name of the table from which to delete the information, such as incident. |
| completion | @escaping (Result\<Void, NowDataError\>) | Completion handler to execute after deleting the specified codable model(s). Return values: * Success: Nothing returned * Failure: NowDataError * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-delete_S_S_O__NowDataErroriOS-ul-enum} {#NTblServ-delete_S_S_O__ul_dpx_jvk_spb} |
[Table 16. Parameters]

{#NTblServ-delete_S_S_O__table_zss_k1l_spb} {#NTblServ-delete_S_S_O__table_ats_k1l_spb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 17. Returns]

{#NTblServ-delete_S_S_O__table_ats_k1l_spb}  
The following code example shows how to call this function.

    tableService.delete(Incident(sysId: sysId), from: tableName) { [weak self] result in
      switch result {
        case .success:
          // Delete successfully
        case .failure(let error):
          // Failed to delete with NowDataError
      }
    }

## NowTableService - delete(_ model: Model, from tableName: String) {#ariaid-title10}

Deletes the specified Codable model from the specified table.
Note:  
This method has been deprecated. You should use the async/await implementation of the method instead.
{#NTblServ-delete_S_S__table_qvl_lzk_spb__entry__3}

| Name | Type | Description |
|-|-|-|
| model | Model | `SysIdentifiableModel` to delete from the table. It should contain the sys_id of the record to delete. |
| from tableName | String | Name of the table from which to delete the information, such as incident. |
[Table 18. Parameters]

{#NTblServ-delete_S_S__table_qvl_lzk_spb} {#NTblServ-delete_S_S__table_rvl_lzk_spb__entry__2}

| Type | Description |
|-|-|
| AnyPublisher\<Void, NowDataError\> | Success: Nothing returned Failure: NowDataError * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-delete_S_S__NowDataErroriOS-ul-enum} |
[Table 19. Returns]

{#NTblServ-delete_S_S__table_rvl_lzk_spb}  
The following code example shows how to call this function.

    tableService.delete(Incident(sysId: sysId), from: tableName)
      .subscribe(on: DispatchQueue.global())
      .receive(on: DispatchQueue.main)
      .sink { [weak self] completion in
        switch completion {
          case .finished:
            // Delete successfully
          case .failure(let error):
            // Failed to delete with NowDataError
        }
      } receiveValue: { _ in
      }
      .store(in: &subscriptions)

## NowTableService - deleteRecord(sysId: SysID, from tableName: String) async throws {#ariaid-title11}

Deletes the specified record from the specified table.
{#NTblServ-deleteRecord-async_S_S__table_nvk_2vj_ppb__entry__3}

| Name | Type | Description |
|-|-|-|
| sysId | String | Sys_id of the record to delete. |
| from tableName | String | Name of the table from which to delete the information, such as incident. |
[Table 20. Parameters]

{#NTblServ-deleteRecord-async_S_S__table_nvk_2vj_ppb} {#NTblServ-deleteRecord-async_S_S__table_ovk_2vj_ppb__entry__2}

| Type | Description |
|-|-|
| None | Nothing returned when the method is successful. |
| NowDataError | Thrown when the method fails. * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-deleteRecord-async_S_S__NowDataErroriOS-ul-enum} |
[Table 21. Returns]

{#NTblServ-deleteRecord-async_S_S__table_ovk_2vj_ppb}  
The following code examples shows how to call this method.

    do {
        try await tableService.deleteRecord(sysId: sysId, from: tableName)
        print("Deletion successful.")
    } catch {
        print("Deletion failed with NowDataError: \(error)")
    }

## NowTableService - deleteRecord(sysId: SysID, from tableName: String, completion: @escaping
(Result\<Void, NowDataError\>)) {#ariaid-title12}

Deletes the specified record from the specified table and then executes the
completion object after the record is deleted.
{#NTblServ-deleteRecord_S_S_O__table_krx_yvj_ppb__entry__3}

| Name | Type | Description |
|-|-|-|
| sysId | String | Sys_id of the record to delete. |
| from tableName | String | Name of the table from which to delete the information, such as incident. |
| completion | @escaping (Result\<Void, NowDataError\>) | Success: Nothing is returned. Failure: NowDataError * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-deleteRecord_S_S_O__NowDataErroriOS-ul-enum} |
[Table 22. Parameters]

{#NTblServ-deleteRecord_S_S_O__table_krx_yvj_ppb} {#NTblServ-deleteRecord_S_S_O__table_lrx_yvj_ppb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 23. Returns]

{#NTblServ-deleteRecord_S_S_O__table_lrx_yvj_ppb}  
The following code example shows how to call this function.

    tableService.deleteRecord(sysId: sysId, from: tableName) { [weak self] result in
      switch result {
        case .success:
          // Delete successfully
        case .failure(let error):
          // Failed to delete with NowDataError
      }
    }

## NowTableService - deleteRecord(sysId: SysID, from tableName: String) {#ariaid-title13}

Deletes the specified record from the specified table.
Note:  
This method has been deprecated. You should use the async/await implementation of the method instead.
{#NTblServ-deleteRecord_S_S__table_nvk_2vj_ppb__entry__3}

| Name | Type | Description |
|-|-|-|
| sysId | String | Sys_id of the record to delete. |
| from tableName | String | Name of the table from which to delete the information, such as incident. |
[Table 24. Parameters]

{#NTblServ-deleteRecord_S_S__table_nvk_2vj_ppb} {#NTblServ-deleteRecord_S_S__table_ovk_2vj_ppb__entry__2}

| Type | Description |
|-|-|
| AnyPublisher\<Void, NowDataError\> | Success: Nothing returned Failure: NowDataError * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-deleteRecord_S_S__NowDataErroriOS-ul-enum} |
[Table 25. Returns]

{#NTblServ-deleteRecord_S_S__table_ovk_2vj_ppb}  
This example shows how to create a function that deletes a record in a specified table.

    tableService.deleteRecord(sysId: sysId, from: tableName) 
        .subscribe(on: DispatchQueue.global())
        .receive(on: DispatchQueue.main)
        .sink { completion in
            switch completion {
            case .finished:
                print("Record deleted.")
            case .failure(let error):
                print("Deletion failed with NowDataError: \(error)")
            }
        } receiveValue: { _ in }
        .store(in: &subscriptions)

## NowServiceTable - init(configuration: NowServiceConfiguration, coreServiceProvider:
NowCoreServiceProviding? = nil) {#ariaid-title14}

Creates a NowTableService object.
{#NTblServ-init_S_S__table_djd_fv3_ppb__entry__3}

| Name | Type | Description |
|-|-|-|
| configuration | [NowServiceConfiguration](https://servicenow-prod.fluidtopics.net/A6W2zQ0fOO_VQ9lbo3VKwQ#NowServiceConfigurationiOSStruct "The NowServiceConfiguration structure defines configuration information for a feature service.") | Configuration parameters to use when creating the service. |
| coreServiceProvider | NowCoreServiceProviding | Optional. Service provider to associate with the NowTableService. Default: nil |
[Table 26. Parameters]

{#NTblServ-init_S_S__table_djd_fv3_ppb}  
The following code example shows how to call this function.

    guard let coreService = NowSDK.core() else {
      // Error with NowServiceError.sdkNotConfigured
      return
    }

    guard 
      let instanceUrl = URL(string: "http://sample.service-now.com") , 
      let serviceConfig = NowSDK.makeServiceConfiguration(for: instanceUrl) else {
        // Could not create service -- 
        // NowServiceError.serviceConfigurationInvalid
        return
      }
    let tableService = NowTableService (configuration: serviceConfig, coreServiceProvider: coreService)

## NowTableService - model\<Model: Decodable\>(with sysId: SysID? = nil, from tableName: String, path: String = Constants.resultPath, coder: Coder = .default, configuration: FetchConfiguration? = nil) async throws {#ariaid-title15}

Enables the retrieval of decodable model(s) from a specified table.
Table API responses are nested inside a result parameter similar to the following:

    {
      "result": [
        { "name": "Ash Williams" },
        { "name": "Lionel Cosgrove" },
        { "name": "Laurie Strode" }
      ]
    }

For large result sets, use one of the paginator functions, [NowTableService - paginator(from tableName: String, configuration: FetchConfiguration? = nil)](https://servicenow-prod.fluidtopics.net/Mg9nOO4u3WPRvIqz4t9SUw#NTblServ-paginator_S_O "Creates a paginator that enables iterating through pages of records.") or [NowTableService - paginator\<Model: Decodable\>(from tableName: String, path: String = Constants.resultPath, coder: Coder = .default, configuration: FetchConfiguration? = nil)](https://servicenow-prod.fluidtopics.net/Mg9nOO4u3WPRvIqz4t9SUw#NTblServ-paginator_S_S_S_O "Creates a paginator that enables the iteration of pages of decoded model(s) that handle nesting.") to fetch paginated models.
{#NTblServ-model-async_S_S_S_S_O__table_nbq_yyj_spb__entry__3}{#NTblServ-model-async_S_S_S_S_O__mobilesdkiOS-tableName-entry}

| Name | Type | Description |
|-|-|-|
| with sysId | SysID | Optional. Sys_id of the record to return. Provide the sys_id if you want to retrieve a specific record. Default: nil |
| from tableName | String | Name of the table from which to retrieve the records, such as incident. |
| path | String | Dot separated path for the nested type. For example, `result` or `foo.bar.baz` for deeper nesting. Default: `result` |
| coder | Coder | Optional. `Coder` to use to encode or decode data sent to and received from the ServiceNow instance. Possible values: * default: The default encoders format dates using the `yyy-MM-dd HH:mm:ss` format by using the device `Locale` and `TimeZone`. * custom(JSONEncoder, JSONDecoder): Use `custom` coders to have more fine-grained control on JSON decoding/encoding. Only use this enumeration to supply your own `JSONEncoder` and `JSONDecoder`, for example when using special date formats, time zones, or locales. let myEncoder = JSONEncoder() myEncoder.dateFormat = ... let myDecoder = JSONDecoder() myDecoder.dateFormat = ... let coder: Coder = .custom(myEncoder, myDecoder) {#NTblServ-model-async_S_S_S_S_O__ul_nx3_wrd_sqb} Default: .default |
| configuration | [FetchConfiguration](https://servicenow-prod.fluidtopics.net/l6lFs6UaAdGVvttsDa2ucw#FetchConfigiOSStructure "The FetchConfiguration structure provides the ability to define the configuration for fetching records from your ServiceNow instance.") | Optional. Configuration to apply to the retrieved records, including filters that define the records to return, pagination page size limit, which fields to retrieve, and what to include in the fields. Default: nil - All records returned. |
[Table 27. Parameters]

{#NTblServ-model-async_S_S_S_S_O__table_nbq_yyj_spb} {#NTblServ-model-async_S_S_S_S_O__table_obq_yyj_spb__entry__2}

| Type | Description |
|-|-|
| Model | Returned when the method is successful. Decodable model(s). |
| NowDataError | Thrown when the method fails. * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-model-async_S_S_S_S_O__NowDataErroriOS-ul-enum} |
[Table 28. Returns]

{#NTblServ-model-async_S_S_S_S_O__table_obq_yyj_spb}  
The following code example shows how to call this method.

    struct User: Codable { 
        var name: String
    } 

    let service: NowTableService = ... 
    do {
        let result = try await service.model([User].self, from: "sys_user", path: "result")
        print("Fetched \(users.count) users")
    } catch {
        dump(error) 
    }

The following code example shows how to fetch a single Decodable model by sys_id. Use a single model type, such as `User.self`, rather than `[User].self`.

    let result = try await service.model(User.self, with: "5137153cc611227c000bbd1bd8cd2005", from: "sys_user", path: "result") 

## NowTableService - model\<Model: Decodable\>(_ type: Model.Type, with sysId: SysID? = nil,
from tableName: String, path: String = Constants.resultPath, coder: Coder = .default,
configuration: FetchConfiguration? = nil, completion: @escaping (Result\<Model,
NowDataError\>)) {#ariaid-title16}

Retrieves decodable model(s) from a specified table.
Table API responses are nested inside a result parameter similar to the following:

    {
      "result": [
        { "name": "Ash Williams" },
        { "name": "Lionel Cosgrove" },
        { "name": "Laurie Strode" }
      ]
    }

Use this function to obtain decodable models instead of nested output.
{#NTblServ-model_S_S_S_S_S_O_O__table_trc_vfk_spb__entry__3}{#NTblServ-model_S_S_S_S_S_O_O__mobilesdkiOS-tableName-entry}

| Name | Type | Description |
|-|-|-|
| type | Model.Type | Type of value to decode. |
| with sysId | String | Optional. Sys_id of the record to return. Default: All records returned per the configuration settings. |
| from tableName | String | Name of the table from which to retrieve the records, such as incident. |
| path | String | Optional. Dot separated path for the nested type. For example, `result` or `foo.bar.baz` for deeper nesting. Default: `Constants.resultPath` |
| coder | Coder | Optional. `Coder` to use to encode or decode data sent to and received from the ServiceNow instance. Default: `.default` |
| configuration | [FetchConfiguration](https://servicenow-prod.fluidtopics.net/l6lFs6UaAdGVvttsDa2ucw#FetchConfigiOSStructure "The FetchConfiguration structure provides the ability to define the configuration for fetching records from your ServiceNow instance.") | Optional. Configuration to apply to the retrieved records, including filters that define the records to return, pagination page size limit, which fields to retrieve, and what to include in the fields. Default: nil - All records returned. |
| completion | @escaping (Result\<Model, NowDataError\>) | Completion handler to execute after retrieving the specified decodable model(s). Return values for the completion handler: * Success: Data for the requested model type. * Failure: NowDataError * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-model_S_S_S_S_S_O_O__NowDataErroriOS-ul-enum} |
[Table 29. Parameters]

{#NTblServ-model_S_S_S_S_S_O_O__table_trc_vfk_spb} {#NTblServ-model_S_S_S_S_S_O_O__table_urc_vfk_spb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 30. Returns]

{#NTblServ-model_S_S_S_S_S_O_O__table_urc_vfk_spb}  
To retrieve a collection of decoded User models.

    struct User: SysIdentifiableModel {
        var sysId: String = ""
        var name: String
    }
    let service: NowTableService = ...
    let user = User(name: "Ash Williams")
    service.create(Incident(fields: fields), in: tableName, writeOptions: writeOptions, configuration: fetchConfiguration) { [weak self] result in
      switch result {
      case .success(let newUser):
        /// 'newUser' contains the platform assigned 'sys_id', use in subsequent 'update' or 'delete' calls.
      case .failure(let error):
       ...
     }
    }

To fetch a single decodable model by sys_id, use a single model type, such as
`User.self`, rather than `[User].self`.

    service.model(User.self, with: "5137153cc611227c000bbd1bd8cd2005", from: "sys_user", path: "result") { resultin ... }

## NowTableService - model\<Model: Decodable\>(with sysId: SysID? = nil, from tableName:
String, path: String = Constants.resultPath, coder: Coder = .default, configuration:
FetchConfiguration? = nil) {#ariaid-title17}

Creates a publisher that enables the retrieval of decodable model(s) from a specified
table.
Note:  
This method has been deprecated. You should use the async/await implementation of the method instead.  
Table API responses are nested inside a result parameter similar to the following:

    {
      "result": [
        { "name": "Ash Williams" },
        { "name": "Lionel Cosgrove" },
        { "name": "Laurie Strode" }
      ]
    }

For large result sets, use one of the paginator functions, [NowTableService - paginator(from tableName: String, configuration: FetchConfiguration? = nil)](https://servicenow-prod.fluidtopics.net/Mg9nOO4u3WPRvIqz4t9SUw#NTblServ-paginator_S_O "Creates a paginator that enables iterating through pages of records.") or [NowTableService - paginator\<Model: Decodable\>(from tableName: String, path: String = Constants.resultPath, coder: Coder = .default, configuration: FetchConfiguration? = nil)](https://servicenow-prod.fluidtopics.net/Mg9nOO4u3WPRvIqz4t9SUw#NTblServ-paginator_S_S_S_O "Creates a paginator that enables the iteration of pages of decoded model(s) that handle nesting.") to fetch paginated models.
{#NTblServ-model_S_S_S_S_O__table_nbq_yyj_spb__entry__3}{#NTblServ-model_S_S_S_S_O__mobilesdkiOS-tableName-entry}

| Name | Type | Description |
|-|-|-|
| with sysId | SysID | Optional. Sys_id of the record to return. Provide the sys_id if you want to retrieve a specific record. Default: nil |
| from tableName | String | Name of the table from which to retrieve the records, such as incident. |
| path | String | Dot separated path for the nested type. For example, `result` or `foo.bar.baz` for deeper nesting. Default: `result` |
| coder | Coder | Optional. `Coder` to use to encode or decode data sent to and received from the ServiceNow instance. Possible values: * default: The default encoders format dates using the `yyy-MM-dd HH:mm:ss` format by using the device `Locale` and `TimeZone`. * custom(JSONEncoder, JSONDecoder): Use `custom` coders to have more fine-grained control on JSON decoding/encoding. Only use this enumeration to supply your own `JSONEncoder` and `JSONDecoder`, for example when using special date formats, time zones, or locales. let myEncoder = JSONEncoder() myEncoder.dateFormat = ... let myDecoder = JSONDecoder() myDecoder.dateFormat = ... let coder: Coder = .custom(myEncoder, myDecoder) {#NTblServ-model_S_S_S_S_O__ul_nx3_wrd_sqb} Default: .default |
| configuration | [FetchConfiguration](https://servicenow-prod.fluidtopics.net/l6lFs6UaAdGVvttsDa2ucw#FetchConfigiOSStructure "The FetchConfiguration structure provides the ability to define the configuration for fetching records from your ServiceNow instance.") | Optional. Configuration to apply to the retrieved records, including filters that define the records to return, pagination page size limit, which fields to retrieve, and what to include in the fields. Default: nil - All records returned. |
[Table 31. Parameters]

{#NTblServ-model_S_S_S_S_O__table_nbq_yyj_spb} {#NTblServ-model_S_S_S_S_O__table_obq_yyj_spb__entry__2}

| Type | Description |
|-|-|
| AnyPublisher\<Model, NowDataError\> | Success: Publisher returning a decodable model(s). Failure: NowDataError * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-model_S_S_S_S_O__NowDataErroriOS-ul-enum} |
[Table 32. Returns]

{#NTblServ-model_S_S_S_S_O__table_obq_yyj_spb}  
To obtain a publisher that provides decoded User models by type, such as
`[Users].self`, fetch the models by specifying a dot-separated path.

    struct User: Codable {
      varname: String
    }

    let service: NowTableService = ...
    let publisher: AnyPublisher<[User], NowDataError> = service.model(from: "sys_user", path: "user.photos.gps_location")
     
To fetch a single decodable model by sys_id, use a single `User.self` model
type, rather than `[User].self`.

    let publisher: AnyPublisher<User, NowDataError> = service.model(with: "5137153cc611227c000bbd1bd8cd2005", from: "sys_user", path: "result")

## NowTableService - paginator(from tableName: String, configuration: FetchConfiguration? =
nil) {#ariaid-title18}

Creates a paginator that enables iterating through pages of records.
The paginator's publisher emits data that you can decode into a custom [Codable model](https://developer.apple.com/documentation/foundation/archives_and_serialization/encoding_and_decoding_custom_types), or you can also use the [NowTableService - paginator\<Model: Decodable\>(from tableName: String, path: String = Constants.resultPath, coder: Coder = .default, configuration: FetchConfiguration? = nil)](https://servicenow-prod.fluidtopics.net/Mg9nOO4u3WPRvIqz4t9SUw#NTblServ-paginator_S_S_S_O "Creates a paginator that enables the iteration of pages of decoded model(s) that handle nesting.") function. Alternatively, you can use the convenience function convertToRecords() to transform data into a NowRecord object. The following shows how to convert a publisher to emit NowRecords:

    let dataPublisher: AnyPublisher<Data, NowDataError> = ...
    let recordsPublisher: AnyPublisher<[NowRecord], NowDataError> = myPublisher.convertToRecords()

Note:  
Unless overridden in the configuration parameter, a paginator returns 20 items per page. Depending on ACL evaluation, the actual number of fetched items for a page might be less than the default or configured value.
{#NTblServ-paginator_S_O__id_fpc_pcj_ppb__entry__3}{#NTblServ-paginator_S_O__mobilesdkiOS-tableName-row}

| Name | Type | Description |
|-|-|-|
| tableName | String | Name of the table from which to retrieve the records, such as incident. |
| configuration | [FetchConfiguration](https://servicenow-prod.fluidtopics.net/l6lFs6UaAdGVvttsDa2ucw#FetchConfigiOSStructure "The FetchConfiguration structure provides the ability to define the configuration for fetching records from your ServiceNow instance.") | Optional. Configuration to apply to the retrieved records, including filters that define the records to return, pagination page size limit, which fields to retrieve, and what to include in the fields. Default: nil - All records returned. |
[Table 33. Parameters]

{#NTblServ-paginator_S_O__id_fpc_pcj_ppb} {#NTblServ-paginator_S_O__table_uwv_wv3_ppb__entry__2}

| Type | Description |
|-|-|
| Paginator\<Data\> | Success: Paginator object containing the specified records. Failure: NowDataError * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-paginator_S_O__NowDataErroriOS-ul-enum} |
[Table 34. Returns]

{#NTblServ-paginator_S_O__table_uwv_wv3_ppb}  

    private var tableService: NowTableService?
    // Paginator creation uses type inference to determine the response type.
    private var paginator: Paginator<[CustomerServiceCase]>?

    func initializeTableService(for instanceUrl: URL) {
      makeTableService(instanceUrl: instanceUrl) { [weak self] result in
        guard let self = self else { return }
                
        switch result {
        case .success(let tableService):
          self.tableService = tableService
          // Create a paginator that iterates over pages of customer support cases. The paginator's response type is
          // inferred from the paginator's type definition (e.g. `Paginator<[CustomerServiceCase]>`).
          self.paginator = tableService.paginator(from: Self.tableName, configuration: self.fetchConfiguration)
          // Subscribe to the paginator's publisher so you are able to receive paged results.
          self.subscribeToPaginatorPublisher()
          // Ready to start fetching data, inform the view controller.
          self.onReady(self)
        case .failure(let error):
          debugPrint("Creating table service failed with error: \(error.localizedDescription)")
          self.tableService = nil
          self.paginator = nil
        }
      }
    }

## NowTableService - paginator\<Model: Decodable\>(from tableName: String, path: String =
Constants.resultPath, coder: Coder = .default, configuration: FetchConfiguration? = nil) {#ariaid-title19}

Creates a paginator that enables the iteration of pages of decoded model(s) that handle
nesting.
The ServiceNow REST Table API responses are nested inside a result property similar to the following:

    {
      "result": [
        { "name": "Ash Williams" },
        { "name": "Lionel Cosgrove" },
        { "name": "Laurie Strode" }
      ]
    }

To obtain a paginator that provides decoded User models, fetch the paginator by specifying a dot-separated path; in this case, result.

    struct User: Codable {
      varname: String
    }

    let service: NowTableService = ...
    let paginator: Paginator<[User]> = service.paginator(from: "sys_user", path: "result")

Note:  
Unless overridden in the configuration parameter, a paginator returns 20 items per page. Depending on the ACL evaluations, the actual number of fetched items for a page might be less than the default or configured value.  
After obtaining a Paginator object, subscribe to its Combine Publisher to start receiving data:

    paginator.publisher
      .subscribe(on: DispatchQueue.global())
      .receive(on: DispatchQueue.main)
      .sink { ... }
      .store(in: &subscriptions)

Note:  
As with all Combine subscriptions, ensure that you retain the subscription to avoid unexpected results.
{#NTblServ-paginator_S_S_S_O__table_vds_gtj_spb__entry__3}{#NTblServ-paginator_S_S_S_O__mobilesdkiOS-tableName-entry}

| Name | Type | Description |
|-|-|-|
| from tableName | String | Name of the table from which to retrieve the records, such as incident. |
| path | String | Dot separated path for the nested type. For example, `result` or `result.user.photos` for deeper nesting. Specifying a custom path allows fetching or iterating over nested data*.* Default: `result` |
| coder | Coder | Optional. `Coder` to use to encode or decode data sent to and received from the ServiceNow instance. Possible values: * default: The default encoders format dates using the `yyy-MM-dd HH:mm:ss` format by using the device `Locale` and `TimeZone`. * custom(JSONEncoder, JSONDecoder): Use `custom` coders to have more fine-grained control on JSON decoding/encoding. Only use this enumeration to supply your own `JSONEncoder` and `JSONDecoder`, for example when using special date formats, time zones, or locales. let myEncoder = JSONEncoder() myEncoder.dateFormat = ... let myDecoder = JSONDecoder() myDecoder.dateFormat = ... let coder: Coder = .custom(myEncoder, myDecoder) {#NTblServ-paginator_S_S_S_O__ul_nx3_wrd_sqb} Default: .default |
| configuration | [FetchConfiguration](https://servicenow-prod.fluidtopics.net/l6lFs6UaAdGVvttsDa2ucw#FetchConfigiOSStructure "The FetchConfiguration structure provides the ability to define the configuration for fetching records from your ServiceNow instance.") | Optional. Configuration to apply to the retrieved records, including filters that define the records to return, pagination page size limit, which fields to retrieve, and what to include in the fields. Default: nil - All records returned. |
[Table 35. Parameters]

{#NTblServ-paginator_S_S_S_O__table_vds_gtj_spb} {#NTblServ-paginator_S_S_S_O__table_wds_gtj_spb__entry__2}

| Type | Description |
|-|-|
| Paginator\<Data\> | Success: Paginator object containing paged `Decodable` model(s). Failure: NowDataError * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-paginator_S_S_S_O__NowDataErroriOS-ul-enum} |
[Table 36. Returns]

{#NTblServ-paginator_S_S_S_O__table_wds_gtj_spb}  
This example shows how to obtain a Paginator object that provides decoded User models. You
can fetch the desired Paginator object by hinting the compiler to return a collection of
User models (\[User\]) and informing the Paginator object that the users are nested beneath
the result path.

    struct User: Codable {
      var name: String
    }

    let service: NowTableService = ...
    let paginator: Paginator<[User]> = service.paginator(from: "sys_user", path: "result")

Note:  
The Table API always returns results nested beneath a result path, so you can safely eliminate the path parameter.

## NowTableService - record(with sysId: SysID, from tableName: String, configuration: FieldReadConfiguration? = nil) async throws {#ariaid-title20}

Retrieves a specified record from the specified table on a ServiceNow instance.
The publisher emits data that you can decode into a custom [Codable model](https://developer.apple.com/documentation/foundation/archives_and_serialization/encoding_and_decoding_custom_types), or you can also use the [NowTableService - paginator\<Model: Decodable\>(from tableName: String, path: String = Constants.resultPath, coder: Coder = .default, configuration: FetchConfiguration? = nil)](https://servicenow-prod.fluidtopics.net/Mg9nOO4u3WPRvIqz4t9SUw#NTblServ-paginator_S_S_S_O "Creates a paginator that enables the iteration of pages of decoded model(s) that handle nesting.") function. Alternatively, you can use the convenience function convertToRecords() to transform data into a NowRecord object. The following shows how to convert a publisher to emit NowRecords:

    let dataPublisher: AnyPublisher<Data, NowDataError> = ...
    let recordsPublisher: AnyPublisher<[NowRecord], NowDataError> = myPublisher.convertToRecords()

{#NTblServ-record-async_S_S_O__table_fsr_23j_ppb__entry__3}{#NTblServ-record-async_S_S_O__mobilesdkiOS-tableName-entry}

| Name | Type | Description |
|-|-|-|
| sysId | String | Sys_id of the record to return from the ServiceNow instance. |
| from tableName | String | Name of the table from which to retrieve the records, such as incident. |
| configuration | [FetchConfiguration](https://servicenow-prod.fluidtopics.net/l6lFs6UaAdGVvttsDa2ucw#FetchConfigiOSStructure "The FetchConfiguration structure provides the ability to define the configuration for fetching records from your ServiceNow instance.") | Optional. Configuration to apply to the retrieved records, including filters that define the records to return, pagination page size limit, which fields to retrieve, and what to include in the fields. Default: nil - All records returned. |
[Table 37. Parameters]

{#NTblServ-record-async_S_S_O__table_fsr_23j_ppb}{#NTblServ-record-async_S_S_O__table_gsr_23j_ppb__entry__2}

| Type | Description |
|-|-|
| Data | Returned when the method is successful. Data object containing the specified record. |
| NowDataError | Thrown when the method fails. * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-record-async_S_S_O__NowDataErroriOS-ul-enum} |
[Table 38. Returns]

{#NTblServ-record-async_S_S_O__table_gsr_23j_ppb}  
The following code examples shows how to call this method.

    func fetchTableRecord(sysId: String, tableName: String, includeFields: [FieldName] = [FieldName](), readOptions: FieldReadConfiguration.Options = []) async throws -> NowRecord {
        let readConfig = FieldReadConfiguration(includeFields: includeFields, options: readOptions)
        do {
            let dataResult: Data = try await tableService.record(with: sysId, from: tableName, configuration: configuration)
            let recordResult: NowRecord = dataResult.convertToRecord()
            return recordResult
        } catch {
            print("Fetch failed with NowDataError: \(error)")
            throw error
        }
    }

## NowTableService - record(with sysId: SysID, from tableName: String, configuration:
FieldReadConfiguration, completion: @escaping (Result\<Data, NowDataError\>) {#ariaid-title21}

Retrieves the specified record from the specified table and then executes a completion handler after the record is retrieved.
If needed, you can decode the return results into a custom Codable model or you can use the [NowTableService - paginator\<Model: Decodable\>(from tableName: String, path: String = Constants.resultPath, coder: Coder = .default, configuration: FetchConfiguration? = nil)](https://servicenow-prod.fluidtopics.net/Mg9nOO4u3WPRvIqz4t9SUw#NTblServ-paginator_S_S_S_O "Creates a paginator that enables the iteration of pages of decoded model(s) that handle nesting.") function instead. Alternatively, you can use the convenience function convertToRecords() to transform data into a NowRecord object. The following shows how to convert a publisher to emit NowRecords:

    let dataPublisher: AnyPublisher<Data, NowDataError> = ...
    let recordsPublisher: AnyPublisher<[NowRecord], NowDataError> = myResult.convertToRecords()

For large result sets, use the [NowTableService - paginator(from tableName: String, configuration: FetchConfiguration? = nil)](https://servicenow-prod.fluidtopics.net/Mg9nOO4u3WPRvIqz4t9SUw#NTblServ-paginator_S_O "Creates a paginator that enables iterating through pages of records.") function to fetch paginated results.
{#NTblServ-record_S_S_O_O__table_fzv_fnj_ppb__entry__3}{#NTblServ-record_S_S_O_O__mobilesdkiOS-tableName-entry}

| Name | Type | Description |
|-|-|-|
| sysId | String | Sys_id of the record to return from the ServiceNow instance. |
| from tableName | String | Name of the table from which to retrieve the records, such as incident. |
| configuration | [FetchConfiguration](https://servicenow-prod.fluidtopics.net/l6lFs6UaAdGVvttsDa2ucw#FetchConfigiOSStructure "The FetchConfiguration structure provides the ability to define the configuration for fetching records from your ServiceNow instance.") | Optional. Configuration to apply to the retrieved records, including filters that define the records to return, pagination page size limit, which fields to retrieve, and what to include in the fields. Default: nil - All records returned. |
| completion | @escaping (Result\<Data, NowDataError\>) | Completion handler to execute after the records are retrieved. Return values: * Success: Data - Requested records * Error: NowDataError * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-record_S_S_O_O__NowDataErroriOS-ul-enum} {#NTblServ-record_S_S_O_O__ul_uzx_thj_ppb} |
[Table 39. Parameters]

{#NTblServ-record_S_S_O_O__table_fzv_fnj_ppb} {#NTblServ-record_S_S_O_O__table_gzv_fnj_ppb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 40. Returns]

{#NTblServ-record_S_S_O_O__table_gzv_fnj_ppb}  
The following code example shows how to call this method.

    func fetchTableRecords( tableName: String, filterQuery: String, includeFields: [FieldName] = [FieldName](), readOptions: FieldReadConfiguration.Options = [], limit: Int?) {
      let readConfig = FieldReadConfiguration(includeFields: includeFields, options: readOptions)
      let config = FetchConfiguration(Filter(query: filterQuery), limit, readConfig)
      tableService.records (from: tableName, configuration: fetchConfiguration) { [weak self] result in
        switch result {
          case .success(let dataResult):
            let recordResult: [NowRecord] = dataResult.convertToRecords()
            // Return recordResult

          case .failure(let error):
            // Failed to fetch record with NowDataError
        }
      }
    }

## NowTableService - record(with sysId: SysID, from tableName: String, configuration:
FieldReadConfiguration? = nil) {#ariaid-title22}

Creates a publisher to retrieve a specified record from the specified table on a ServiceNow instance.
Note:  
This method has been deprecated. You should use the async/await implementation of the method instead.
The publisher emits data that you can decode into a custom [Codable model](https://developer.apple.com/documentation/foundation/archives_and_serialization/encoding_and_decoding_custom_types), or you can also use the [NowTableService - paginator\<Model: Decodable\>(from tableName: String, path: String = Constants.resultPath, coder: Coder = .default, configuration: FetchConfiguration? = nil)](https://servicenow-prod.fluidtopics.net/Mg9nOO4u3WPRvIqz4t9SUw#NTblServ-paginator_S_S_S_O "Creates a paginator that enables the iteration of pages of decoded model(s) that handle nesting.") function. Alternatively, you can use the convenience function convertToRecords() to transform data into a NowRecord object. The following shows how to convert a publisher to emit NowRecords:

    let dataPublisher: AnyPublisher<Data, NowDataError> = ...
    let recordsPublisher: AnyPublisher<[NowRecord], NowDataError> = myPublisher.convertToRecords()

{#NTblServ-record_S_S_O__table_fsr_23j_ppb__entry__3}{#NTblServ-record_S_S_O__mobilesdkiOS-tableName-entry}

| Name | Type | Description |
|-|-|-|
| sysId | String | Sys_id of the record to return from the ServiceNow instance. |
| from tableName | String | Name of the table from which to retrieve the records, such as incident. |
| configuration | [FetchConfiguration](https://servicenow-prod.fluidtopics.net/l6lFs6UaAdGVvttsDa2ucw#FetchConfigiOSStructure "The FetchConfiguration structure provides the ability to define the configuration for fetching records from your ServiceNow instance.") | Optional. Configuration to apply to the retrieved records, including filters that define the records to return, pagination page size limit, which fields to retrieve, and what to include in the fields. Default: nil - All records returned. |
[Table 41. Parameters]

{#NTblServ-record_S_S_O__table_fsr_23j_ppb}{#NTblServ-record_S_S_O__table_gsr_23j_ppb__entry__2}

| Type | Description |
|-|-|
| AnyPublisher\<Data, NowDataError\> | Success: Data object containing the specified records. Failure: NowDataError * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-record_S_S_O__NowDataErroriOS-ul-enum} |
[Table 42. Returns]

{#NTblServ-record_S_S_O__table_gsr_23j_ppb}  
This example shows how to create a function that retrieves the specified record from the
specified table, with the specified fields. The output of the call is a ByteArray which
allows you to convert the data into any model that you want.

    tableService.record(with: sysId, from: tableName, configuration: fetchConfiguration)
        .subscribe(on: DispatchQueue.global())
        .receive(on: DispatchQueue.main)
        .convertToRecord()
        .sink { completion in
            if case let .failure(error) = completion {
                print("Record retrieval failed with NowDataError: \(error)")
            }
        } receiveValue: { record in
            print("Successfully retrieved record: \(record)")
        }
        .store(in: &subscriptions)

## NowTableService - records(from tableName: String, configuration: FetchConfiguration? = nil) async throws {#ariaid-title23}

Retrieves records from the specified table.
The publisher emits data that you can decode into a custom [Codable model](https://developer.apple.com/documentation/foundation/archives_and_serialization/encoding_and_decoding_custom_types), or you can also use the [NowTableService - paginator\<Model: Decodable\>(from tableName: String, path: String = Constants.resultPath, coder: Coder = .default, configuration: FetchConfiguration? = nil)](https://servicenow-prod.fluidtopics.net/Mg9nOO4u3WPRvIqz4t9SUw#NTblServ-paginator_S_S_S_O "Creates a paginator that enables the iteration of pages of decoded model(s) that handle nesting.") function. Alternatively, you can use the convenience function convertToRecords() to transform data into a NowRecord object. The following shows how to convert a publisher to emit NowRecords:

    let dataPublisher: AnyPublisher<Data, NowDataError> = ...
    let recordsPublisher: AnyPublisher<[NowRecord], NowDataError> = myPublisher.convertToRecords()

For large result sets, use the [NowTableService - paginator(from tableName: String, configuration: FetchConfiguration? = nil)](https://servicenow-prod.fluidtopics.net/Mg9nOO4u3WPRvIqz4t9SUw#NTblServ-paginator_S_O "Creates a paginator that enables iterating through pages of records.") function to fetch paginated results.
{#NTblServ-records-async_S_O__id_rzw_lcj_ppb__entry__3}{#NTblServ-records-async_S_O__mobilesdkiOS-tableName-entry}

| Name | Type | Description |
|-|-|-|
| from tableName | String | Name of the table from which to retrieve the records, such as incident. |
| configuration | [FetchConfiguration](https://servicenow-prod.fluidtopics.net/l6lFs6UaAdGVvttsDa2ucw#FetchConfigiOSStructure "The FetchConfiguration structure provides the ability to define the configuration for fetching records from your ServiceNow instance.") | Optional. Configuration to apply to the retrieved records, including filters that define the records to return, pagination page size limit, which fields to retrieve, and what to include in the fields. Default: nil - All records returned. |
[Table 43. Parameters]

{#NTblServ-records-async_S_O__id_rzw_lcj_ppb} {#NTblServ-records-async_S_O__table_yvr_d1j_ppb__entry__2}

| Type | Description |
|-|-|
| Data | Returned when the method is successful. Data object containing the specified records. |
| NowDataError | Thrown when the method fails. * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-records-async_S_O__NowDataErroriOS-ul-enum} |
[Table 44. Returns]

{#NTblServ-records-async_S_O__table_yvr_d1j_ppb}  
The following code example shows how to call this method.

    func fetchTableRecords( tableName: String, filterQuery: String,
     includeFields: [FieldName] = [FieldName](), readOptions:
     FieldReadConfiguration.Options = [], limit: Int?) {
        let readConfig = FieldReadConfiguration(includeFields: includeFields, options: readOptions)
        let config = FetchConfiguration(Filter(query: filterQuery), limit, readConfig)
        do {
          let dataResult: Data = try await tableService.records(from: tableName, configuration: config)
          let recordResult: [NowRecord] = dataResult.convertToRecords()
          // return recordResult
        } catch {
          print("Fetch failed with NowDataError: \(error)")
          throw error 
      }
    }

## NowTableService - records(from tableName: String, configuration: FetchConfiguration? = nil,
completion: @escaping (Result\<Data, NowDataError\>)) {#ariaid-title24}

Retrieves records from a specified table and then executes the completion handler after the records are retrieved.
If needed, you can decode the return results into a custom Codable model or you can use the [NowTableService - paginator\<Model: Decodable\>(from tableName: String, path: String = Constants.resultPath, coder: Coder = .default, configuration: FetchConfiguration? = nil)](https://servicenow-prod.fluidtopics.net/Mg9nOO4u3WPRvIqz4t9SUw#NTblServ-paginator_S_S_S_O "Creates a paginator that enables the iteration of pages of decoded model(s) that handle nesting.") function instead. Alternatively, you can use the convenience function convertToRecords() to transform data into a NowRecord object. The following shows how to convert a publisher to emit NowRecords:

    let dataPublisher: AnyPublisher<Data, NowDataError> = ...
    let recordsPublisher: AnyPublisher<[NowRecord], NowDataError> = myResult.convertToRecords()

For large result sets, use the [NowTableService - paginator(from tableName: String, configuration: FetchConfiguration? = nil)](https://servicenow-prod.fluidtopics.net/Mg9nOO4u3WPRvIqz4t9SUw#NTblServ-paginator_S_O "Creates a paginator that enables iterating through pages of records.") function to fetch paginated results.
{#NTblServ-records_S_O_O__table_uvc_y2j_ppb__entry__3}

| Name | Type | Description |
|-|-|-|
| in tableName | String | Name of the table in which to write the records, such as incident. |
| configuration | [FetchConfiguration](https://servicenow-prod.fluidtopics.net/l6lFs6UaAdGVvttsDa2ucw#FetchConfigiOSStructure "The FetchConfiguration structure provides the ability to define the configuration for fetching records from your ServiceNow instance.") | Optional. Configuration to apply to the retrieved records, including filters that define the records to return, pagination page size limit, which fields to retrieve, and what to include in the fields. Default: nil - All records returned. |
| completion | @escaping (Result\<Data, NowDataError\>) | Completion handler to execute after the records are retrieved. Return values: * Success: Data - Requested records * Error: NowDataError * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-records_S_O_O__NowDataErroriOS-ul-enum} {#NTblServ-records_S_O_O__ul_uzx_thj_ppb} |
[Table 45. Parameters]

{#NTblServ-records_S_O_O__table_uvc_y2j_ppb} {#NTblServ-records_S_O_O__table_vvc_y2j_ppb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 46. Returns]

{#NTblServ-records_S_O_O__table_vvc_y2j_ppb}  
The following code example shows how to call this method.

    func fetchTableRecords( tableName: String, filterQuery: String, includeFields: [FieldName] = [FieldName](), readOptions: FieldReadConfiguration.Options = [], limit: Int?) {
      let readConfig = FieldReadConfiguration(includeFields: includeFields, options: readOptions)
      let config = FetchConfiguration(Filter(query: filterQuery), limit, readConfig)
      tableService.records (from: tableName, configuration: fetchConfiguration) { [weak self] result in
        switch result {
          case .success(let dataResult):
            let recordResult: [NowRecord] = dataResult.convertToRecords()
            // return recordResult

          case .failure(let error):
            // Failed to fetch record with NowDataError
        }
      }
    }

## NowTableService - records(from tableName: String, configuration: FetchConfiguration? =
nil) {#ariaid-title25}

Creates a publisher that enable you to retrieve records from the specified
table.
Note:  
This method has been deprecated. You should use the async/await implementation of the method instead.  
The publisher emits data that you can decode into a custom [Codable model](https://developer.apple.com/documentation/foundation/archives_and_serialization/encoding_and_decoding_custom_types), or you can also use the [NowTableService - paginator\<Model: Decodable\>(from tableName: String, path: String = Constants.resultPath, coder: Coder = .default, configuration: FetchConfiguration? = nil)](https://servicenow-prod.fluidtopics.net/Mg9nOO4u3WPRvIqz4t9SUw#NTblServ-paginator_S_S_S_O "Creates a paginator that enables the iteration of pages of decoded model(s) that handle nesting.") function. Alternatively, you can use the convenience function convertToRecords() to transform data into a NowRecord object. The following shows how to convert a publisher to emit NowRecords:

    let dataPublisher: AnyPublisher<Data, NowDataError> = ...
    let recordsPublisher: AnyPublisher<[NowRecord], NowDataError> = myPublisher.convertToRecords()

For large result sets, use the [NowTableService - paginator(from tableName: String, configuration: FetchConfiguration? = nil)](https://servicenow-prod.fluidtopics.net/Mg9nOO4u3WPRvIqz4t9SUw#NTblServ-paginator_S_O "Creates a paginator that enables iterating through pages of records.") function to fetch paginated results.
{#NTblServ-records_S_O__id_rzw_lcj_ppb__entry__3}{#NTblServ-records_S_O__mobilesdkiOS-tableName-entry}

| Name | Type | Description |
|-|-|-|
| from tableName | String | Name of the table from which to retrieve the records, such as incident. |
| configuration | [FetchConfiguration](https://servicenow-prod.fluidtopics.net/l6lFs6UaAdGVvttsDa2ucw#FetchConfigiOSStructure "The FetchConfiguration structure provides the ability to define the configuration for fetching records from your ServiceNow instance.") | Optional. Configuration to apply to the retrieved records, including filters that define the records to return, pagination page size limit, which fields to retrieve, and what to include in the fields. Default: nil - All records returned. |
[Table 47. Parameters]

{#NTblServ-records_S_O__id_rzw_lcj_ppb} {#NTblServ-records_S_O__table_yvr_d1j_ppb__entry__2}

| Type | Description |
|-|-|
| AnyPublisher\<Data, NowDataError\> | Success: Data object containing the specified records. Failure: NowDataError * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-records_S_O__NowDataErroriOS-ul-enum} |
[Table 48. Returns]

{#NTblServ-records_S_O__table_yvr_d1j_ppb}  
This example shows how to create a function that fetches multiple records from a specified
table. It creates an object which will schedule the request to be executed at some point in
the future and return a ByteArray response.

    tableService.records(from: tableName, configuration: fetchConfiguration)
        .subscribe(on: DispatchQueue.global())
        .receive(on: DispatchQueue.main)
        .convertToRecords()
        .sink { completion in
            if case let .failure(error) = completion {
                print("Record retrieval failed with NowDataError: \(error)")
            }
        } receiveValue: { records in
            print("Successfully retrieved records: \(records)")
        }
        .store(in: &subscriptions)

## NowTableService - update\<Model: SysIdentifiableModel\>(_ model: Model, in tableName: String, coder: Coder = .default, writeOptions: FieldWriteOptions? = nil, configuration: FetchConfiguration? = nil) async throws {#ariaid-title26}

Updates the specified Codable model in the specified table.
{#NTblServ-update-async_S_S_S_O_O__table_n4q_3yk_spb__entry__3}

| Name | Type | Description |
|-|-|-|
| model | Model | `SysIdentifiableModel` model to update in the table. |
| in tableName | String | Name of the table in which to write the records, such as incident. |
| coder | Coder | Optional. `Coder` to use to encode or decode data sent to and received from the ServiceNow instance. Possible values: * default: The default encoders format dates using the `yyy-MM-dd HH:mm:ss` format by using the device `Locale` and `TimeZone`. * custom(JSONEncoder, JSONDecoder): Use `custom` coders to have more fine-grained control on JSON decoding/encoding. Only use this enumeration to supply your own `JSONEncoder` and `JSONDecoder`, for example when using special date formats, time zones, or locales. let myEncoder = JSONEncoder() myEncoder.dateFormat = ... let myDecoder = JSONDecoder() myDecoder.dateFormat = ... let coder: Coder = .custom(myEncoder, myDecoder) {#NTblServ-update-async_S_S_S_O_O__ul_nx3_wrd_sqb} Default: .default |
| writeOptions | [FieldWriteOptions](https://servicenow-prod.fluidtopics.net/QnzQhyqUjnNQnz_YHU0hhw#FieldWriteOptionsiOSStruct "The FieldWriteOptions class provides functions that set the options for updating or creating fields in a record on a ServiceNow instance.") | Optional. Configuration options to apply to the data being written to the record. Default: nil |
| configuration | [FetchConfiguration](https://servicenow-prod.fluidtopics.net/l6lFs6UaAdGVvttsDa2ucw#FetchConfigiOSStructure "The FetchConfiguration structure provides the ability to define the configuration for fetching records from your ServiceNow instance.") | Optional. Configuration to apply to the retrieved records, including filters that define the records to return, pagination page size limit, which fields to retrieve, and what to include in the fields. Default: nil - All records returned. |
[Table 49. Parameters]

{#NTblServ-update-async_S_S_S_O_O__table_n4q_3yk_spb} {#NTblServ-update-async_S_S_S_O_O__table_o4q_3yk_spb__entry__2}

| Type | Description |
|-|-|
| Model | Returned when the method is successful. Decodable model that was updated in the specified table. |
| NowDataError | Thrown when the method fails. * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-update-async_S_S_S_O_O__NowDataErroriOS-ul-enum} |
[Table 50. Returns]

{#NTblServ-update-async_S_S_S_O_O__table_o4q_3yk_spb}  
The following code examples shows how to call this method.

    struct User: SysIdentifiableModel {
        var sysId: String = ""
        var name: String}
         
    func updateUser(user: User) async throws -> User {
        do {
            let result = try await tableService.update(user, in: "sys_user")
            return result
        } catch {
            print("Update failed with NowDataError: \(error)")
            throw error
        }
    }

## NowTableService - update\<Model: SysIdentifiableModel\>(_ model: Model, in tableName:
String, coder: Coder = .default, writeOptions: FieldWriteOptions? = nil, configuration:
FetchConfiguration? = nil, completion: @escaping (Result\<Model, NowDataError\>)) {#ariaid-title27}

Updates the specified Codable model in the specified table and then executes the
completion handler.
{#NTblServ-update_S_S_S_O_O_O__table_nmv_vpr_spb__entry__3}

| Name | Type | Description |
|-|-|-|
| model | Model | `SysIdentifiableModel` model to update in the table. |
| in tableName | String | Name of the table in which to write the records, such as incident. |
| coder | Coder | Optional. `Coder` to use to encode or decode data sent to and received from the ServiceNow instance. Possible values: * default: The default encoders format dates using the `yyy-MM-dd HH:mm:ss` format by using the device `Locale` and `TimeZone`. * custom(JSONEncoder, JSONDecoder): Use `custom` coders to have more fine-grained control on JSON decoding/encoding. Only use this enumeration to supply your own `JSONEncoder` and `JSONDecoder`, for example when using special date formats, time zones, or locales. let myEncoder = JSONEncoder() myEncoder.dateFormat = ... let myDecoder = JSONDecoder() myDecoder.dateFormat = ... let coder: Coder = .custom(myEncoder, myDecoder) {#NTblServ-update_S_S_S_O_O_O__ul_nx3_wrd_sqb} Default: .default |
| writeOptions | [FieldWriteOptions](https://servicenow-prod.fluidtopics.net/QnzQhyqUjnNQnz_YHU0hhw#FieldWriteOptionsiOSStruct "The FieldWriteOptions class provides functions that set the options for updating or creating fields in a record on a ServiceNow instance.") | Optional. Configuration options to apply to the data being written to the record. Default: nil |
| configuration | [FetchConfiguration](https://servicenow-prod.fluidtopics.net/l6lFs6UaAdGVvttsDa2ucw#FetchConfigiOSStructure "The FetchConfiguration structure provides the ability to define the configuration for fetching records from your ServiceNow instance.") | Optional. Configuration to apply to the retrieved records, including filters that define the records to return, pagination page size limit, which fields to retrieve, and what to include in the fields. Default: nil - All records returned. |
| completion | @escaping (Result\<Model, NowDataError\>) | Completion handler to execute after updating the specified Codable model(s). Return values: * Success: Model * Failure: NowDataError * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-update_S_S_S_O_O_O__NowDataErroriOS-ul-enum} {#NTblServ-update_S_S_S_O_O_O__ul_dpx_jvk_spb} |
[Table 51. Parameters]

{#NTblServ-update_S_S_S_O_O_O__table_nmv_vpr_spb} {#NTblServ-update_S_S_S_O_O_O__table_omv_vpr_spb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 52. Returns]

{#NTblServ-update_S_S_S_O_O_O__table_omv_vpr_spb}  
The following code example shows how to call this method.

    struct User: SysIdentifiableModel {
      var sysId: String = ""
      var name: String
    }

    let user = User(sysId: "12345", name: "abel")
    let coder: Coder = .default

    tableService.update(user, in: "sys_user") { [weak self] result in
      switch result {
        case .success(let model):
          do {
            let data = try coder.jsonEncoder.encode(model)
            self?.publish(data: data)
          } catch {
            self?.publish(result: .failure(error))
          }            
        case .failure(let error):
          // Failed to update with NowDataError
          self?.publish(result: .failure(error))
      }
    }

## NowTableService - update\<Model: SysIdentifiableModel\>(_ model: Model, in tableName:
String, coder: Coder = .default, writeOptions: FieldWriteOptions? = nil, configuration:
FetchConfiguration? = nil) {#ariaid-title28}

Updates the specified codable model in the specified table.
Note:  
This method has been deprecated. You should use the async/await implementation of the method instead.
{#NTblServ-update_S_S_S_O_O__table_n4q_3yk_spb__entry__3}

| Name | Type | Description |
|-|-|-|
| model | Model | `SysIdentifiableModel` model to update in the table. |
| in tableName | String | Name of the table in which to write the records, such as incident. |
| coder | Coder | Optional. `Coder` to use to encode or decode data sent to and received from the ServiceNow instance. Possible values: * default: The default encoders format dates using the `yyy-MM-dd HH:mm:ss` format by using the device `Locale` and `TimeZone`. * custom(JSONEncoder, JSONDecoder): Use `custom` coders to have more fine-grained control on JSON decoding/encoding. Only use this enumeration to supply your own `JSONEncoder` and `JSONDecoder`, for example when using special date formats, time zones, or locales. let myEncoder = JSONEncoder() myEncoder.dateFormat = ... let myDecoder = JSONDecoder() myDecoder.dateFormat = ... let coder: Coder = .custom(myEncoder, myDecoder) {#NTblServ-update_S_S_S_O_O__ul_nx3_wrd_sqb} Default: .default |
| writeOptions | [FieldWriteOptions](https://servicenow-prod.fluidtopics.net/QnzQhyqUjnNQnz_YHU0hhw#FieldWriteOptionsiOSStruct "The FieldWriteOptions class provides functions that set the options for updating or creating fields in a record on a ServiceNow instance.") | Optional. Configuration options to apply to the data being written to the record. Default: nil |
| configuration | [FetchConfiguration](https://servicenow-prod.fluidtopics.net/l6lFs6UaAdGVvttsDa2ucw#FetchConfigiOSStructure "The FetchConfiguration structure provides the ability to define the configuration for fetching records from your ServiceNow instance.") | Optional. Configuration to apply to the retrieved records, including filters that define the records to return, pagination page size limit, which fields to retrieve, and what to include in the fields. Default: nil - All records returned. |
[Table 53. Parameters]

{#NTblServ-update_S_S_S_O_O__table_n4q_3yk_spb} {#NTblServ-update_S_S_S_O_O__table_o4q_3yk_spb__entry__2}

| Type | Description |
|-|-|
| AnyPublisher\<Model, NowDataError\> | Success: Decodable models that were updated in the specified table. Failure: NowDataError * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-update_S_S_S_O_O__NowDataErroriOS-ul-enum} |
[Table 54. Returns]

{#NTblServ-update_S_S_S_O_O__table_o4q_3yk_spb}  
The following code example shows how to call this method.

    struct User: SysIdentifiableModel {
      var sysId: String = ""
      var name: String
    }

    let user = User(sysId: "12345", name: "abel")
    let coder: Coder = .default

    tableService.update(user, in: "sys_user")
      .subscribe(on: DispatchQueue.global())
      .receive(on: DispatchQueue.main)
      .sink { [weak self] completion in
        if case let .failure(error) = completion {
          // Failed to update with NowDataError
          self?.publish(result: .failure(error))
        }
      } receiveValue: { [weak self] updatedModel in
        do {
          let data = try coder.jsonEncoder.encode(updatedModel)
          self?.publish(data: data)
        } catch {
          // Failed to update with NowDataError
          self?.publish(result: .failure(error))
        }
      }
      .store(in: &subscriptions)

## NowTableService - updateRecord(sysId: SysID, in tableName: String, withfields: \[FieldName: FieldValue\], writeOptions: FieldWriteOptions? = nil, configuration: FieldReadConfiguration? = nil) async throws {#ariaid-title29}

Updates the specified record with the specified fields.
You can decode the data into a custom [Codable model](https://developer.apple.com/documentation/foundation/archives_and_serialization/encoding_and_decoding_custom_types), or you can use the [NowTableService - paginator\<Model: Decodable\>(from tableName: String, path: String = Constants.resultPath, coder: Coder = .default, configuration: FetchConfiguration? = nil)](https://servicenow-prod.fluidtopics.net/Mg9nOO4u3WPRvIqz4t9SUw#NTblServ-paginator_S_S_S_O "Creates a paginator that enables the iteration of pages of decoded model(s) that handle nesting.") function. Alternatively, you can use the convenience function convertToRecords() to transform data into a NowRecord object. The following shows how to convert a publisher to emit NowRecords:

    let dataPublisher: AnyPublisher<Data, NowDataError> = ...
    let recordsPublisher: AnyPublisher<[NowRecord], NowDataError> = myPublisher.convertToRecords()

Note:  
All fields within a record may not be available for update. For example, fields that have a prefix of `sys_` are typically system parameters that are automatically generated and cannot be updated. Fields that are not specified and not auto-generated by the system are set to the associated data type's null value.
{#NTblServ-updateRecord-async_S_A_O_O__table_cjl_5sj_ppb__entry__3}

| Name | Type | Description |
|-|-|-|
| sysId | String | Sys_id of the record to return from the ServiceNow instance. |
| with fields | \[FieldName: FieldValue\] | Name-value pairs of the fields to include in the record. |
| in tableName | String | Name of the table in which to write the records, such as incident. |
| writeOptions | [FieldWriteOptions](https://servicenow-prod.fluidtopics.net/QnzQhyqUjnNQnz_YHU0hhw#FieldWriteOptionsiOSStruct "The FieldWriteOptions class provides functions that set the options for updating or creating fields in a record on a ServiceNow instance.") | Optional. Configuration options to apply to the data being written to the record. Default: nil |
| configuration | [FetchConfiguration](https://servicenow-prod.fluidtopics.net/l6lFs6UaAdGVvttsDa2ucw#FetchConfigiOSStructure "The FetchConfiguration structure provides the ability to define the configuration for fetching records from your ServiceNow instance.") | Optional. Configuration to apply to the retrieved records, including filters that define the records to return, pagination page size limit, which fields to retrieve, and what to include in the fields. Default: nil - All records returned. |
[Table 55. Parameters]

{#NTblServ-updateRecord-async_S_A_O_O__table_cjl_5sj_ppb} {#NTblServ-updateRecord-async_S_A_O_O__table_djl_5sj_ppb__entry__2}

| Type | Description |
|-|-|
| Data | Returned when the method is successful. Data object containing the updated record. |
| NowDataError | Thrown when the method fails. * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-updateRecord-async_S_A_O_O__NowDataErroriOS-ul-enum} |
[Table 56. Returns]

{#NTblServ-updateRecord-async_S_A_O_O__table_djl_5sj_ppb}  
The following code examples shows how to call this method.

    do { 
        let dataResult: Data = try await tableService.updateRecord(with: fields, in: tableName, writeOptions: writeOptions, configuration: configuration) 
        let recordResult: NowRecord = dataResult.convertToRecord() 
    } catch { 
        print("Record update failed with NowDataError: \(error)") 
    }

## NowTableService - updateRecord(sysId: SysID, in tableName: String, with fields: \[FieldName:
FieldValue\], writeOptions: FieldWriteOptions? = nil, configuration: FieldReadConfiguration? =
nil, completion: @escaping (Result\<Data, NowDataError\>) {#ariaid-title30}

Updates the specified record with the specified fields then executes the
completion handler once the record is saved.
If needed, you can decode the return results into a custom Codable model or you can use the [NowTableService - paginator\<Model: Decodable\>(from tableName: String, path: String = Constants.resultPath, coder: Coder = .default, configuration: FetchConfiguration? = nil)](https://servicenow-prod.fluidtopics.net/Mg9nOO4u3WPRvIqz4t9SUw#NTblServ-paginator_S_S_S_O "Creates a paginator that enables the iteration of pages of decoded model(s) that handle nesting.") function instead. Alternatively, you can use the convenience function convertToRecords() to transform data into a NowRecord object. The following shows how to convert a publisher to emit NowRecords:

    let dataPublisher: AnyPublisher<Data, NowDataError> = ...
    let recordsPublisher: AnyPublisher<[NowRecord], NowDataError> = myResult.convertToRecords()

Note:  
All fields within a record may not be available for update. For example, fields that have a prefix of `sys_` are typically system parameters that are automatically generated and cannot be updated. Fields that are not specified and not auto-generated by the system are set to the associated data type's null value.
{#NTblServ-updateRecord_S_A_O_O_O__table_jq5_ttj_ppb__entry__3}

| Name | Type | Description |
|-|-|-|
| sysId | String | Sys_id of the record to return from the ServiceNow instance. |
| with fields | \[FieldName: FieldValue\] | Name-value pairs of the fields to include in the record. |
| in tableName | String | Name of the table in which to write the records, such as incident. |
| writeOptions | [FieldWriteOptions](https://servicenow-prod.fluidtopics.net/QnzQhyqUjnNQnz_YHU0hhw#FieldWriteOptionsiOSStruct "The FieldWriteOptions class provides functions that set the options for updating or creating fields in a record on a ServiceNow instance.") | Optional. Configuration options to apply to the data being written to the record. Default: nil |
| configuration | [FetchConfiguration](https://servicenow-prod.fluidtopics.net/l6lFs6UaAdGVvttsDa2ucw#FetchConfigiOSStructure "The FetchConfiguration structure provides the ability to define the configuration for fetching records from your ServiceNow instance.") | Optional. Configuration to apply to the retrieved records, including filters that define the records to return, pagination page size limit, which fields to retrieve, and what to include in the fields. Default: nil - All records returned. |
| completion | @escaping (Result\<Data, NowDataError\>) | Completion handler to execute after the records are retrieved. Return values: * Success: Data - Requested records * Error: NowDataError * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-updateRecord_S_A_O_O_O__NowDataErroriOS-ul-enum} {#NTblServ-updateRecord_S_A_O_O_O__ul_uzx_thj_ppb} |
[Table 57. Parameters]

{#NTblServ-updateRecord_S_A_O_O_O__table_jq5_ttj_ppb} {#NTblServ-updateRecord_S_A_O_O_O__table_kq5_ttj_ppb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 58. Returns]

{#NTblServ-updateRecord_S_A_O_O_O__table_kq5_ttj_ppb}  
The following code example shows how to call this method.

    tableService.updateRecord(sysId: sysId, in: tableName, with: fields, writeOptions: writeOptions, configuration: readConfiguration) { [weak self] result in
      switch result {
        case .success(let data):
          self?.publish(data: data)
        case .failure(let error):
           // Failed to update with NowDataError
      }
    }

## NowTableService - updateRecord(sysId: SysID, in tableName: String, withfields: \[FieldName:
FieldValue\], writeOptions: FieldWriteOptions? = nil, configuration: FieldReadConfiguration? =
nil) {#ariaid-title31}

Updates the specified record with the specified fields.
Note:  
This method has been deprecated. You should use the async/await implementation of the method instead.  
The publisher emits data that you can decode into a custom [Codable model](https://developer.apple.com/documentation/foundation/archives_and_serialization/encoding_and_decoding_custom_types), or you can also use the [NowTableService - paginator\<Model: Decodable\>(from tableName: String, path: String = Constants.resultPath, coder: Coder = .default, configuration: FetchConfiguration? = nil)](https://servicenow-prod.fluidtopics.net/Mg9nOO4u3WPRvIqz4t9SUw#NTblServ-paginator_S_S_S_O "Creates a paginator that enables the iteration of pages of decoded model(s) that handle nesting.") function. Alternatively, you can use the convenience function convertToRecords() to transform data into a NowRecord object. The following shows how to convert a publisher to emit NowRecords:

    let dataPublisher: AnyPublisher<Data, NowDataError> = ...
    let recordsPublisher: AnyPublisher<[NowRecord], NowDataError> = myPublisher.convertToRecords()

Note:  
All fields within a record may not be available for update. For example, fields that have a prefix of `sys_` are typically system parameters that are automatically generated and cannot be updated. Fields that are not specified and not auto-generated by the system are set to the associated data type's null value.
{#NTblServ-updateRecord_S_A_O_O__table_cjl_5sj_ppb__entry__3}

| Name | Type | Description |
|-|-|-|
| sysId | String | Sys_id of the record to return from the ServiceNow instance. |
| with fields | \[FieldName: FieldValue\] | Name-value pairs of the fields to include in the record. |
| in tableName | String | Name of the table in which to write the records, such as incident. |
| writeOptions | [FieldWriteOptions](https://servicenow-prod.fluidtopics.net/QnzQhyqUjnNQnz_YHU0hhw#FieldWriteOptionsiOSStruct "The FieldWriteOptions class provides functions that set the options for updating or creating fields in a record on a ServiceNow instance.") | Optional. Configuration options to apply to the data being written to the record. Default: nil |
| configuration | [FetchConfiguration](https://servicenow-prod.fluidtopics.net/l6lFs6UaAdGVvttsDa2ucw#FetchConfigiOSStructure "The FetchConfiguration structure provides the ability to define the configuration for fetching records from your ServiceNow instance.") | Optional. Configuration to apply to the retrieved records, including filters that define the records to return, pagination page size limit, which fields to retrieve, and what to include in the fields. Default: nil - All records returned. |
[Table 59. Parameters]

{#NTblServ-updateRecord_S_A_O_O__table_cjl_5sj_ppb} {#NTblServ-updateRecord_S_A_O_O__table_djl_5sj_ppb__entry__2}

| Type | Description |
|-|-|
| AnyPublisher\<Data, NowDataError\> | Success: Data object containing the updated record. Failure: NowDataError * `accessToken(AccessTokenProviderError)` * AccessTokenProviderError: The access token provider's error code or message. * accessTokenRetrievalFailed * userSessionError(_ error: Error) Thrown when there is an error in the access token. * `attachmentValidation` Thrown when an attachment fails validation. * `badResponse(statusCode: HTTPStatusCode)` * HTTPStatusCode: Status code received from the instance. Thrown when a request returns an unexpected response * `cannotDecodeModel(DecodingError)` * DecodingError: Decoding error detected. Thrown when a Codable model cannot be decoded from JSON. * `cannotDecodeProperty(type: Any, from: String)` * type: Wrapped type to decode from a string. * from: String to decode to the specified type. Thrown when a string-wrapped value cannot be decoded from JSON. * `cannotEncodeModel(EncodingError)` * EncodingError: Encoding error detected. Thrown when a Codable model cannot be encoded to JSON. * `cannotParseResponse` Thrown when a response from the instance cannot be parsed into its expected format. * `invalidURL` Thrown when a URL cannot be formed. For example, if the string contains characters that are illegal in a URL or is an empty string. * `missingAttachmentMetadata` Thrown when the attachment metadata header is missing. * `missingServiceConfiguration` Thrown when an expected service configuration is missing. * `missingSysID` Thrown when an expected sys_id parameter is missing. * `network(NetworkServiceError)` * genericError(String) * operationCanceled * serviceDisabled * serverError(Error) * systemError(Error) Thrown when a network service encountered an error. {#NTblServ-updateRecord_S_A_O_O__NowDataErroriOS-ul-enum} |
[Table 60. Returns]

{#NTblServ-updateRecord_S_A_O_O__table_djl_5sj_ppb}  
This example shows how to create a function that updates a record in the specified table,
with the specified fields. The output of the call is a ByteArray which allows you to convert
the data into any model that you want.

    tableService.updateRecord(sysId: sysId, in: tableName, with: fields, writeOptions: writeOptions, configuration: readConfiguration)
        .subscribe(on: DispatchQueue.global())
        .receive(on: DispatchQueue.main)
        .convertToRecord()
        .sink { completion in
            if case let .failure(error) = completion {
                print("Update failed with NowDataError: \(error)")
            }
        } receiveValue: { record in
            print("Record updated: \(record)")
        }
        .store(in: &subscriptions)


