{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":1145,"path":"api-reference/server-api-reference/sn_erp_integrationBothAPI.md","title":"sn\\_erp\\_integration API - Scoped, Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# sn\\_erp\\_integration API- Scoped, Global\n\nScript include providing a chainable API for interacting with Zero Copy Connector for ERP \\(Enterprise Resource Planning\\) models.\n\nThis script include requires the Zero Copy Connector for ERP \\(com.sn\\_erp\\_integration\\) store application and is provided within the sn\\_erp\\_integration namespace. For more information, refer to [Zero Copy Connector for ERP](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/integrate-applications/erp-integration-overview.md).\n\nRole required: sn\\_erp\\_integration.erp\\_user\n\n-   **Metadata**\n\n    Use metadata methods to discover the system, model, and IDoc information available in your Zero Copy Connector for ERP environment.\n\n    -   getAvailableSystems\\(\\)\n    -   getAvailableModels\\(\\)\n    -   getAvailableOperations\\(\\)\n    -   getAvailableInputs\\(\\)\n    -   getRequiredInputs\\(\\)\n    -   getAvailableOutputs\\(\\)\n    -   getAvailableIdocConfigs\\(\\)\n-   **Configuration**\n\n    Use configuration methods to select available systems, models, operations, and IDoc configurations for processing. You can also use these methods to filter model field return values.\n\n    -   system\\(\\)\n    -   model\\(\\)\n    -   operation\\(\\)\n    -   idocConfig\\(\\)\n    -   fields\\(\\)\n    -   limit\\(\\)\n    -   offset\\(\\)\n-   **Query building**\n\n    Use query building methods to filter results.\n\n    -   addEncodedQuery\\(\\)\n    -   addQuery\\(\\)\n    -   addOrQuery\\(\\)\n-   **Data input**\n\n    Use the data input methods to set field values. The withJSON\\(\\)method can be used for input on nested objects and IDoc fields. The set\\(\\) method is used to set a single field value.\n\n    -   set\\(\\)\n    -   withJSON\\(\\)\n-   **Operation execution**\n\n    Use the execute\\(\\) method when working with multiple records, and the get\\(\\) method for results of a single record.\n\n    -   execute\\(\\)\n    -   get\\(\\)\n\n**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)\n\n## API - API constructor\n\nInitializes a new Zero Copy Connector for ERP API instance.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| ||\n\nThe following examples show how to create an instance of the API to access an ERP system.\n\n```\n// Select the system1 system\nconst api = new sn_erp_integration.API().system('system1');\n```\n\n## API - addEncodedQuery\\(String encodedQuery\\)\n\nFilters records using an encoded query.\n\nSee also:\n\n-   [API - addOrQuery\\(String field, String operator, String value\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md)\n-   [API - addQuery\\(String field, String operator, String value, String joinType\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md)\n-   [API - fields\\(Array fields\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md)\n\n|Name|Type|Description|\n|----|----|-----------|\n|encodedQuery|String|An [encoded query string](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-user-interface/c_EncodedQueryStrings.md).|\n\n|Type|Description|\n|----|-----------|\n|Object|Returns this instance for chaining.|\n\nThe following example shows how to use an encoded query to retrieve company codes in the US.\n\n```\nconst api = new sn_erp_integration.API()\n  .system('system1')\n  .model('company_code')\n  .operation('read')\n  .addEncodedQuery('company_codes_countryregion_key=US')\n  .execute();\n```\n\n## API - addOrQuery\\(String field, String operator, String value\\)\n\nAdd an OR query condition.\n\nSee also:\n\n-   [API - addEncodedQuery\\(String encodedQuery\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md)\n-   [API - addQuery\\(String field, String operator, String value, String joinType\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md)\n-   [API - fields\\(Array fields\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md)\n\n<table id=\"table_qkt_53x_3hc\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfield\n\n</td><td>\n\nString\n\n</td><td>\n\nThe name of the field to be queried.\n\n</td></tr><tr><td>\n\noperator\n\n</td><td>\n\nString\n\n</td><td>\n\nOptional. Query operator. The query option used depends on whether data provided for the *value* parameter is a number or string.Default value: =\n\nNumbers:\n\n-   =\n-   !=\n-   &gt;\n-   &gt;=\n-   &lt;\n-   &lt;=\n\nStrings \\(must be in upper case\\):\n\n-   =\n-   !=\n-   IN\n-   NOT IN\n-   STARTSWITH\n-   ENDSWITH\n-   CONTAINS\n-   DOES NOT CONTAIN\n\n**Note:** Use CONTAINS instead of the LIKE operator.\n\n</td></tr><tr><td>\n\nvalue\n\n</td><td>\n\nString\n\n</td><td>\n\nValue on which to query \\(not case-sensitive\\).\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|Object|Returns this instance for chaining.|\n\nThe following example shows how to return all company codes in the US and Canada.\n\n```\nconst api = new sn_erp_integration.API();\nconst companyCodes = api\n  .system('system1')\n  .model('company_code')\n  .operation('read')\n  .addQuery('company_codes_countryregion_key', 'US')\n  .addOrQuery('company_codes_countryregion_key', 'CA')\n  .fields(['company_codes_company_code', 'company_codes_company_name', 'company_codes_countryregion_key', 'company_codes_currency'])\n  .execute();\n\n// Process the results\ncompanyCodes.forEach(companyCode => {\n  gs.info('Company Code: ${companyCode.company_codes_company_code}, Name: ${companyCode.company_codes_company_name}, Country: ${companyCode.company_codes_countryregion_key}');\n  \n  // Do something with each company code\n  if (companyCode.company_codes_countryregion_key === 'US') {\n    // Process US company codes\n  } else {\n    // Process Canadian company codes\n  }\n});\n```\n\n## API - addQuery\\(String field, String operator, String value, String joinType\\)\n\nAdd a query condition for filtering data.\n\nSee also:\n\n-   [API - addEncodedQuery\\(String encodedQuery\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md)\n-   [API - addOrQuery\\(String field, String operator, String value\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md)\n-   [API - fields\\(Array fields\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md)\n\n<table id=\"table_qkt_53x_3hc\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfield\n\n</td><td>\n\nString\n\n</td><td>\n\nThe name of the field to be queried.\n\n</td></tr><tr><td>\n\noperator\n\n</td><td>\n\nString\n\n</td><td>\n\nOptional. Query operator. The query option used depends on whether data provided for the *value* parameter is a number or string.Default value: =\n\nNumbers:\n\n-   =\n-   !=\n-   &gt;\n-   &gt;=\n-   &lt;\n-   &lt;=\n\nStrings \\(must be in upper case\\):\n\n-   =\n-   !=\n-   IN\n-   NOT IN\n-   STARTSWITH\n-   ENDSWITH\n-   CONTAINS\n-   DOES NOT CONTAIN\n\n**Note:** Use CONTAINS instead of the LIKE operator.\n\n</td></tr><tr><td>\n\nvalue\n\n</td><td>\n\nString\n\n</td><td>\n\nValue on which to query \\(not case-sensitive\\).\n\n</td></tr><tr><td>\n\njoinType\n\n</td><td>\n\nString\n\n</td><td>\n\nOptional. Join type.Possible values:\n\n-   AND\n-   OR\n\nDefault value: AND\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|Object|Returns this instance for chaining.|\n\nThe following example shows how to use the &gt; operator to return results that are priority one or a priority greater than two.\n\n```\n// Results in: priority=1^ORpriority>2\nconst api = new sn_erp_integration.API();\n  .system('system1')\n  .model('request')\n  .operation('read')\n  .addQuery('priority', '1)\n  .addOrQuery('priority', '>', '2')\n  .execute();\n```\n\n## API - execute\\(\\)\n\nExecutes the configured operation.\n\nTo execute an operation on a single result, use [API - get\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Object\\|Array|The result of the operation. Error if unsuccessful.|\n\nThe following example shows how to create a new company code.\n\n```\nconst newCompanyCode = new sn_erp_integration.API()\n  .system('system1')\n  .model('company_code')\n  .operation('create')\n  .withJSON({\n    company_codes_company_code: '1234',\n    company_codes_company_name: 'New York Office',\n    company_codes_countryregion_key: 'US',\n    company_codes_language_key: 'EN'\n  })\n  .execute();\n```\n\n## API - fields\\(Array fields\\)\n\nSpecifies the model fields to return. This is the primary method for field selection.\n\nTo retrieve a list of fields available for a model, use [API - getAvailableOutputs\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md).\n\nSee also:\n\n-   [API - limit\\(Number max\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md)\n-   [API - offset\\(Number start\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md)\n\n|Name|Type|Description|\n|----|----|-----------|\n|fields|Array|One or more model field names listed as strings.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to return specific fields for all company codes in the US.\n\n```\nconst companyCodes = new API()\n  .system('system1')\n  .model('company_code')\n  .operation('read')\n  .addQuery('company_codes_countryregion_key', 'US')\n  .fields(['company_codes_company_code', 'company_codes_company_name', 'company_codes_countryregion_key'])\n  .execute();\n```\n\n## API - get\\(\\)\n\nAlias for the execute\\(\\) method for retrieving a single record in the results.\n\nSee also [API - execute\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Object|The first result of the operation.|\n\nThe following example shows how to retrieve a specific sales document.\n\n```\nconst salesDoc = new sn_erp_integration.API()\n  .system('system1')\n  .model('sales_document')\n  .operation('read')\n  .addQuery('document_number', '0000123456')\n  .get();\n```\n\n## API - getAvailableIdocConfigs\\(\\)\n\nGets the available IDoc configuration details for the selected system.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_rkt_53x_3hc\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nArray of objects\n\n</td><td>\n\nList of available IDoc configurations. Throws an error if no system has been selected.See also [API - system\\(String systemId\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md).\n\n</td></tr><tr><td>\n\nobject.id\n\n</td><td>\n\nIDoc ID. Use this value to select an IDoc with the [API - idocConfig\\(String configId\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md) method.Data type: String\n\n</td></tr><tr><td>\n\nobject.name\n\n</td><td>\n\nIDoc display name.Data type: String\n\n</td></tr><tr><td>\n\nobject.description\n\n</td><td>\n\nDescription of the IDoc.Data type: String\n\n</td></tr></tbody>\n</table>The following example shows how to get all available IDoc configurations for a selected system.\n\n```\nconst idocConfigs = new sn_erp_integration.API()\n  .system('system1')\n  .getAvailableIdocConfigs();\n\ngs.info(JSON.stringify(idocConfigs, null, 2));\n```\n\nOutput:\n\n```\n[\n  {\n    \"id\": \"OBC0001002\",\n    \"name\": \"Sales Order IDoc\",\n    \"description\": \"IDoc for sales order processing\"\n  },\n  {\n    \"id\": \"OBC0001003\",\n    \"name\": \"Material IDoc\",\n    \"description\": \"IDoc for material core data\"\n  }\n]\n```\n\n## API - getAvailableInputs\\(\\)\n\nReturns a list of all available input fields for the selected operation.\n\nFor a list of only the required input fields for a selected model, use the [API - getRequiredInputs\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md) method.\n\nSee also:\n\n-   [API - addEncodedQuery\\(String encodedQuery\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md)\n-   [API - addOrQuery\\(String field, String operator, String value\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md)\n-   [API - addQuery\\(String field, String operator, String value, String joinType\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md)\n-   [API - system\\(String systemId\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md)\n-   [API - withJSON\\(Object data\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md)\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_rkt_53x_3hc\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nObject\n\n</td><td>\n\nObject describing available inputs and their types.See also [API - system\\(String systemId\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md).\n\n</td></tr><tr><td>\n\nobject.variable\\_name\n\n</td><td>\n\nVariable name of the input field.Data type: String\n\n</td></tr><tr><td>\n\nobject.label\n\n</td><td>\n\nDisplay name of the input field.Data type: String\n\n</td></tr><tr><td>\n\nobject.data\\_type\n\n</td><td>\n\nData type of the operation input.Data type: String\n\n</td></tr><tr><td>\n\nobject.required\n\n</td><td>\n\nFlag that indicates whether the input field is required.Valid values:\n\n-   true: The input field is required.\n-   false: The input field isn’t required.\n\nData type: Boolean\n\n</td></tr></tbody>\n</table>Get available inputs for creating a company code.\n\n```\nconst inputs = new sn_erp_integration.API()\n  .system('system1')\n  .model('company_code')\n  .operation('read')\n  .getAvailableInputs();\n\ngs.info(JSON.stringify(operations, null, 2));\n```\n\nOutput:\n\n```\n[\n  {\n    \"variable_name\": \"company_codes_company_code\",\n    \"label\": \"Company Code\",\n    \"data_type\": \"string\",\n    \"required\": true\n  },\n  {\n    \"variable_name\": \"company_codes_company_name\",\n    \"label\": \"Company Name\",\n    \"data_type\": \"string\",\n    \"required\": true\n  }\n]\n```\n\n## API - getAvailableModels\\(\\)\n\nReturns a list of available models for the selected system.\n\nFor more information, see\n\n-   [API - model\\(String modelId\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md)\n-   [Building and managing models to work with ERP data](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/integrate-applications/work-with-erp-data-models.md)\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_rkt_53x_3hc\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nArray of objects\n\n</td><td>\n\nList of available models listed as a JSON object with an ID, name, and description property. Throws an error if no system has been selected.See also [API - system\\(String systemId\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md).\n\n</td></tr><tr><td>\n\nobject.id\n\n</td><td>\n\nModel ID. Use this value to select a model with the [API - model\\(String modelId\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md) method.Data type: String\n\n</td></tr><tr><td>\n\nobject.name\n\n</td><td>\n\nModel label, that is, the display name.Data type: String\n\n</td></tr><tr><td>\n\nobject.description\n\n</td><td>\n\nDescription of the model.Data type: String\n\n</td></tr></tbody>\n</table>The following example shows how to retrieve all available models for a selected system.\n\n```\n// Get all available models for system1\nconst models = new sn_erp_integration.API()\n  .system('system1')\n  .getAvailableModels();\n\ngs.info(JSON.stringify(models, null, 2));\n```\n\nOutput:\n\n```\n[\n  {\n    \"id\": \"company_code\",\n    \"name\": \"Company Code\",\n    \"description\": \"Company Code\"\n  },\n  {\n    \"id\": \"country\",\n    \"name\": \"Country\",\n    \"description\": \"Country\"\n  },\n  {\n    \"id\": \"currency\",\n    \"name\": \"Currency\",\n    \"description\": \"Currency\"\n  },\n  {\n    \"id\": \"customer_invoice\",\n    \"name\": \"Customer Invoice\",\n    \"description\": \"Customer Invoice\"\n  },\n  {\n    \"id\": \"language\",\n    \"name\": \"Language\",\n    \"description\": \"Language\"\n  }\n]\n```\n\n## API - getAvailableOperations\\(\\)\n\nGets the available operations for the selected model.\n\nSee also:\n\n-   [API - model\\(String modelId\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md)\n-   [API - operation\\(String operationId\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md)\n-   [API - system\\(String systemId\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md)\n-   [Building and managing models to work with ERP data](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/integrate-applications/work-with-erp-data-models.md)\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_rkt_53x_3hc\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nArray\n\n</td><td>\n\nList of available ERP model operations. Throws an error if no model or system has been selected.\n\n</td></tr><tr><td>\n\nobject.id\n\n</td><td>\n\nModel operation ID. Use this value to select a model operation with the [API - operation\\(String operationId\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md) method.Data type: String\n\n</td></tr><tr><td>\n\nobject.name\n\n</td><td>\n\nModel operation label, that is, the display name.Data type: String\n\n</td></tr></tbody>\n</table>The following example shows how to get all available operations for the **company\\_code** model.\n\n```\nconst operations = new sn_erp_integration.API()\n  .system('system1')\n  .model('company_code')\n  .getAvailableOperations();\n\ngs.info(JSON.stringify(operations, null, 2));\n```\n\nOutput:\n\n```\n[\n  {\n    \"id\": \"create\",\n    \"name\": \"Company Code - Create\"\n  },\n  {\n    \"id\": \"read\",\n    \"name\": \"Company Code - Read\"\n  }\n]\n```\n\n## API - getAvailableOutputs\\(\\)\n\nGets a list of all available output fields for the selected operation.\n\nThe field names returned by this method can be used with the [API - fields\\(Array fields\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md) method to filter field results.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_rkt_53x_3hc\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nArray of objects\n\n</td><td>\n\nList of available output fields. Throws an error if no model or system has been selected.See also [API - system\\(String systemId\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md).\n\n</td></tr><tr><td>\n\nobject.variable\\_name\n\n</td><td>\n\nVariable name of the output field.Data type: String\n\n</td></tr><tr><td>\n\nobject.label\n\n</td><td>\n\nDisplay name of the output field.Data type: String\n\n</td></tr><tr><td>\n\nobject.data\\_type\n\n</td><td>\n\nData type of the operation output.Data type: String\n\n</td></tr></tbody>\n</table>The following example shows how to get the available output provided by reading a model operation called **vendor**.\n\n```\n// Get available outputs for read operation on a vendor model\nconst outputs = new sn_erp_integration.API()\n  .system('system1')\n  .model('vendor')\n  .operation('read')\n  .getAvailableOutputs();\n\ngs.info(JSON.stringify(outputs, null, 2));\n```\n\nOutput:\n\n```\n[\n  {\n    \"variable_name\": \"supplier_country\",\n    \"label\": \"Country\",\n    \"data_type\": \"string\"\n  }\n  {\n    \"variable_name\": \"supplier_city\",\n    \"label\": \"City\",\n    \"data_type\": \"string\"\n  },\n  {\n    \"variable_name\": \"supplier_location\",\n    \"label\": \"Location\",\n    \"data_type\": \"string\"\n  },\n  {\n    \"variable_name\": \"supplier_street\",\n    \"label\": \"Street\",\n    \"data_type\": \"string\"\n  },\n  {\n    \"variable_name\": \"supplier_name\",\n    \"label\": \"Name\",\n    \"data_type\": \"string\"\n  },\n  {\n    \"variable_name\": \"supplier_postal_code\",\n    \"label\": \"Postal Code\",\n    \"data_type\": \"string\"\n  },\n  {\n    \"variable_name\": \"supplier_state\",\n    \"label\": \"State\",\n    \"data_type\": \"string\"\n  }\n]\n```\n\n## API - getAvailableSystems\\(\\)\n\nGets a list of all available ERP systems that can be accessed through the API.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_rkt_53x_3hc\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nArray of objects\n\n</td><td>\n\nList of available ERP systems.\n\n</td></tr><tr><td>\n\nobject.id\n\n</td><td>\n\nSystem ID. Use this value to select a system with the [API - system\\(String systemId\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md) method.Data type: String\n\n</td></tr><tr><td>\n\nobject.name\n\n</td><td>\n\nSystem label, that is, the display name.Data type: String\n\n</td></tr></tbody>\n</table>The following example shows how to get a list of all available ERP systems.\n\n```\nconst systems = new sn_erp_integration.API().getAvailableSystems();\n\ngs.info(JSON.stringify(systems));\n```\n\nOutput:\n\n```\n[\n  {\n    \"id\": \"system1\",\n    \"name\": \"SAP DEV\"\n  },\n  {\n    \"id\": \"system2\",\n    \"name\": \"SAP PROD\"\n  }\n]\n```\n\n## API - getRequiredInputs\\(\\)\n\nReturns of list of only the required input fields for the selected model and create operation.\n\nRequired input fields are set when models are created.\n\nFor a complete list of input fields for a selected model, use the [API - getAvailableInputs\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md) method.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_rkt_53x_3hc\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nArray of objects\n\n</td><td>\n\nList of required input field names.\n\n</td></tr><tr><td>\n\nobject.variable\\_name\n\n</td><td>\n\nVariable name of the required input field.Data type: String\n\n</td></tr><tr><td>\n\nobject.label\n\n</td><td>\n\nDisplay name of the required input field.Data type: String\n\n</td></tr><tr><td>\n\nobject.data\\_type\n\n</td><td>\n\nData type of the operation required input.Data type: String\n\n</td></tr><tr><td>\n\nobject.required\n\n</td><td>\n\nFlag that indicates whether the input field is required. This method only returns results if the value is true.Data type: Boolean\n\n</td></tr></tbody>\n</table>The following example shows how to return the required input fields for creating an invoice.\n\n```\nconst requiredInputs = new sn_erp_integration.API()\n  .system('system1')\n  .model('invoice')\n  .operation('create')\n  .getRequiredInputs();\n\ngs.info(JSON.stringify(requiredInputs, null, 2));\n```\n\nOutput:\n\n```\n{\n  \"variable_name\": \"INVOICE01\",\n  \"label\": \"INVOICE01\",\n  \"data_type\": \"array\",\n  \"required\": true\n}\n```\n\n## API - idocConfig\\(String configId\\)\n\nSelects an IDoc configuration to operate on.\n\nSee also:\n\n-   [Outbound message configuration fields](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/integrate-applications/erp-canvas-add-new-outbound-message-configuration-fields.md)\n-   [Outbound message IDoc status for IDoc log tab fields](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/integrate-applications/erp-canvas-outbound-message-idoc-status-for-idoc-log-tab-columns.md)\n\n|Name|Type|Description|\n|----|----|-----------|\n|configId|String|ID of the IDoc outbound configuration. To retrieve a list of IDoc configuration IDs, use the [API - getAvailableIdocConfigs\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md) method.|\n\n|Type|Description|\n|----|-----------|\n|Object|Returns this instance for chaining.|\n\nThe following example shows how to select an IDoc configuration and set values for processing.\n\n```\nconst api = new sn_erp_integration.API()\n  .system('system1')\n  .idocConfig('OBC0001002')\n  .withJSON({\n    idoc_field1: 'value1',\n    idoc_field2: 'value2'\n  })\n  .execute();\n```\n\n## API - limit\\(Number max\\)\n\nLimits the number of results returned.\n\n|Name|Type|Description|\n|----|----|-----------|\n|max|Number|Maximum number of records to return.|\n\n|Type|Description|\n|----|-----------|\n|Object|Returns this instance for chaining.|\n\nThe following example shows how to retrieve only the first 10 company code records.\n\n```\n// Get only the first 10 company codes\nconst api = new sn_erp_integration.API()\n  .system('system1')\n  .model('company_code')\n  .fields(['company_codes_company_code', 'company_codes_company_name'])\n  .limit(10)\n  .execute();\n```\n\n## API - model\\(String modelId\\)\n\nSelects a model to operate on.\n\n<table id=\"table_qkt_53x_3hc\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nmodelId\n\n</td><td>\n\nString\n\n</td><td>\n\nThe ID of the model.To retrieve a list of all models with their IDs, use [API - getAvailableModels\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md).\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|Object|Returns this instance for chaining.|\n\nThe following example shows how to select the company\\_code model in system1. You can chain additional methods for getting and setting data for the selected model.\n\n```\nconst api = new sn_erp_integration.API()\n  .system('system1')\n  .model('company_code')\n  .execute();\n```\n\n## API - offset\\(Number start\\)\n\nSets the starting offset for results.\n\n|Name|Type|Description|\n|----|----|-----------|\n|start|Number|Starting point at which to begin retrieving results. For example, setting this value to 10 skips the first 10 results returned in a query.|\n\n|Type|Description|\n|----|-----------|\n|Object|Returns this instance for chaining.|\n\nThe following example shows how to retrieve 10 company code records skipping the first 10 results \\(11-20\\).\n\n```\nconst api = new sn_erp_integration.API()\n  .system('system1')\n  .model('company_code')\n  .fields(['company_codes_company_code', 'company_codes_company_name'])\n  .limit(10)\n  .offset(10)\n  .execute();\n```\n\n## API - operation\\(String operationId\\)\n\nSelects an operation to use on a selected model.\n\nTo return a list of model operations, use [API - getAvailableOperations\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|operationId|String|The ID of the model operation.|\n\n|Type|Description|\n|----|-----------|\n|Object|Returns this instance for chaining.|\n\nThe following example shows how to select the read operation for the **company\\_code** model.\n\n```\nconst api = new sn_erp_integration.API()\n  .system('system1')\n  .model('company_code')\n  .operation('read')\n  .execute();\n```\n\n## API - set\\(String field, String value\\)\n\nSets a single field value for create or update operations.\n\n|Name|Type|Description|\n|----|----|-----------|\n|field|String|Name of the field on which to set a value.|\n|value|String|Value to set for the field.|\n\n|Type|Description|\n|----|-----------|\n|Object|Returns this instance for chaining.|\n\nThe following example shows how to create a company code entry and assign field values to it.\n\n```\nconst api = new sn_erp_integration.API()\n  .system('system1')\n  .model('company_code')\n  .operation('create')\n  .set('company_codes_company_code', '1234')\n  .set('company_codes_company_name', 'New York Office')\n  .set('company_codes_countryregion_key', 'US')\n  .set('company_codes_language_key', 'EN')\n  .execute();\n```\n\nThe following example shows how to update a sales document with nested properties. For nested data structures with additional levels, use [API - withJSON\\(Object data\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md).\n\n```\nconst api = new sn_erp_integration.API()\n  .system('system1')\n  .model('sales_document')\n  .operation('update')\n  .set('document_number', '0000123456')\n  .set('header.document_type', 'OR')\n  .set('header.sales_organization', '1000')\n  .execute();\n```\n\n## API - system\\(String systemId\\)\n\nSelects a system to operate on.\n\nSee also:\n\n-   [API - getAvailableSystems\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md)\n-   [API - model\\(String modelId\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md)\n\n|Name|Type|Description|\n|----|----|-----------|\n|systemId|String|The system ID. You can retrieve the system ID using the [API - getAvailableSystems\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md) method.|\n\n|Type|Description|\n|----|-----------|\n|Object|Returns this instance for chaining.|\n\nThe following example shows how to select a system. You can chain additional methods to select a model within the system, and additional methods for using data on the selected system.\n\n```\nconst api = new sn_erp_integration.API().system('system1');\n```\n\n## API - withJSON\\(Object data\\)\n\nSets JSON data for the operation. For read operations, this method sets filter conditions. For create or update operations, this method sets the fields with data to be created or updated.\n\nSee also [API - set\\(String field, String value\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/sn_erp_integrationBothAPI.md).\n\n<table id=\"table_qkt_53x_3hc\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ndata\n\n</td><td>\n\nObject\n\n</td><td>\n\nJSON data listing fields and their values.Format:\n\n```\n{fieldname: 'value'}\n```\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|Object|Returns this instance for chaining.|\n\nThe following example shows how to set data for a create operation.\n\n```\nconst api = new sn_erp_integration.API()\n  .system('system1')\n  .model('company_code')\n  .operation('create')\n  .withJSON({\n    company_codes_company_code: '1234',\n    company_codes_company_name: 'New York Office',\n    company_codes_countryregion_key: 'US'\n  })\n  .execute();\n```\n\nThe following example shows how to set a nested filter for a read operation.\n\n```\nconst api = new sn_erp_integration.API()\n  .system('system1')\n  .model('sales_document')\n  .operation('read')\n  .withJSON({\n    header: {\n      document_type: 'OR',\n      sales_organization: '1000'\n    }\n  })\n  .operation('read')\n  .execute();\n```\n\n"}}