Buckets:
| title: AJAX SDK for JavaScript | Sage Intacct Developer | |
| url: https://developer.intacct.com/platform-services/ajax-sdk-javascript/ | |
| # AJAX SDK for JavaScript | Sage Intacct Developer | |
| Overview | |
| AJAX Gateway | |
| AJAX SDK for JavaScript | |
| Page Script Walkthrough | |
| Application Tutorial | |
| Other Script Examples | |
| Common JavaScript Errors | |
| Trigger Examples | |
| * Overview | |
| * API\_Session | |
| + Parameters | |
| * ip\_create | |
| + Parameters | |
| * ip\_createXML | |
| + Parameters | |
| * ip\_delete | |
| + Parameters | |
| * ip\_inspect | |
| + Parameters | |
| * ip\_getLastRequest | |
| * ip\_read | |
| + Parameters | |
| * ip\_readByName | |
| + Parameters | |
| * ip\_readByQuery | |
| + Parameters | |
| * ip\_readMore | |
| + Parameters | |
| * ip\_readRelated | |
| + Parameters | |
| * ip\_readView | |
| + Parameters | |
| * ip\_update | |
| + Parameters | |
| * ip\_updateXML | |
| + Parameters | |
| --- | |
| ## Overview | |
| Sage Intacct provides an SDK for AJAX via a single JavaScript class in a single file. | |
| This file is included in Platform Services pages to facilitate calling functions. Simply call the `API_Session` constructor to instantiate the class, then call functions in an on-page script (via **Edit this page** in the Sage Intacct UI). The SDK provides wrappers for the generic functions (3.0 versions). | |
| --- | |
| ## API\_Session | |
| You must initiate an AJAX call with this constructor, which establishes an API session using the credentials of the current user. | |
| ```xml | |
| var s = new API_Session(); | |
| ``` | |
| ### Parameters | |
| | Name | Required | Type | Description | | |
| | --- | --- | --- | --- | | |
| | controlid | Optional | string | Control ID (Default: `"foobar"`). | | |
| | uniqueid | Optional | boolean | Enforces uniqueness on `controlid` (Default:`"false"`). | | |
| --- | |
| ## ip\_create | |
| Generates a `create` call. This function has no return value, but the provided example shows how to use a callback to print the response for console logging. | |
| > Creates a new item. Only the required fields are included in the array, but you can add more fields as needed. | |
| ```xml | |
| <script> | |
| function createBeforeSubmit(){ | |
| console.log("In createBeforeSubmit function"); | |
| var fieldsArray = { | |
| 'ITEMID': jq('#MY_ITEMID').val(), | |
| 'STATUS': 'active', | |
| 'NAME': jq('#MY_NAME').val(), | |
| 'ITEMTYPE': 'Non-Inventory' | |
| }; | |
| var api = new API_Session(); | |
| var callback = function(responseText){ | |
| console.log(responseText) | |
| } | |
| api.ip_create('ITEM', fieldsArray, callback); | |
| } | |
| </script> | |
| #myNewItem{ | |
| width:75%; | |
| padding:20px; | |
| margin:20px; | |
| background: #CCCCCC; | |
| } | |
| Item ID | |
| Item Name | |
| Create Item | |
| ``` | |
| ### Parameters | |
| | Name | Required | Type | Description | | |
| | --- | --- | --- | --- | | |
| | object | Required | string | Object name of the object to create. | | |
| | fieldsArray | Required | array | JSON array of field name/value pairs. | | |
| | callback | Optional | string | JavaScript callback function that receives the XML response returned by the server as parameter. | | |
| --- | |
| ## ip\_createXML | |
| Generates a `create` API call using XML content that you provide. | |
| ### Parameters | |
| | Name | Required | Type | Description | | |
| | --- | --- | --- | --- | | |
| | xmlPayload | Required | string | XML text, which may include multiple objects to create. Provide the XML elements that go between `<create></create>` in the XML API `create` function as the payload. | | |
| | callback | Optional | string | JavaScript callback function that receives the XML response returned by the server as parameter. | | |
| --- | |
| ## ip\_delete | |
| Generates a `delete` API call. | |
| ### Parameters | |
| | Name | Required | Type | Description | | |
| | --- | --- | --- | --- | | |
| | object | Required | string | Object name of the object(s) to delete. | | |
| | keys | Required | string | Comma-separated list of keys (typically `RECORDNO`’s to delete). | | |
| | callback | Optional | string | JavaScript callback function that receives the XML response returned by the server as parameter. | | |
| --- | |
| ## ip\_inspect | |
| Generates an `inspect` API on the named object. | |
| ### Parameters | |
| | Name | Required | Type | Description | | |
| | --- | --- | --- | --- | | |
| | object | Required | string | Object name of the object to inspect. | | |
| | detail | Optional | string | 1 provides detailed inspection output (Default: 0). | | |
| | callback | Optional | string | JavaScript callback function that receives the XML response returned by the server as parameter. | | |
| --- | |
| ## ip\_getLastRequest | |
| Returns the last XML request sent to the server. This function can be used for debugging. | |
| --- | |
| ## ip\_read | |
| Generates a `read` API call. | |
| ### Parameters | |
| | Name | Required | Type | Description | | |
| | --- | --- | --- | --- | | |
| | object | Required | string | Object name of the object(s) to get. | | |
| | fields | Required | string | Comma-separated list of fields or \* for all. | | |
| | keys | Required | string | Comma-separated list of keys. | | |
| | returnFormat | Optional | string | `xml`, `csv`, or `json` (Default: xml). | | |
| | docparid | Optional | string | Used for SODOCUMENT and PODOCUMENT records to indicate the document type. Required for custom fields. | | |
| | callback | Optional | string | JavaScript callback function that receives the XML response returned by the server as parameter. | | |
| --- | |
| ## ip\_readByName | |
| Generates a `readByName` API call. | |
| ### Parameters | |
| | Name | Required | Type | Description | | |
| | --- | --- | --- | --- | | |
| | object | Required | string | Object name of the object(s) to get. | | |
| | fields | Required | string | Comma-separated list of fields or \* for all. | | |
| | keys | Required | string | Comma-separated list of keys. | | |
| | returnFormat | Optional | string | `xml`, `csv`, or `json` (Default: xml). | | |
| | callback | Optional | string | JavaScript callback function that receives the XML response returned by the server as parameter. | | |
| --- | |
| ## ip\_readByQuery | |
| Generates a `readByQuery` API call using XML content that you provide. | |
| ### Parameters | |
| | Name | Required | Type | Description | | |
| | --- | --- | --- | --- | | |
| | object | Required | string | Object name of the object(s) to get. | | |
| | fields | Required | string | Comma-separated list of fields or \* for all. | | |
| | query | Required | string | SQL-like query based on fields on the object. The following operators are supported: `<`, `>`, `>=`, `<=`, `=`, `like`, `not like`, `in`, `not in`, `IS NOT NULL`, `IS NULL`, `AND`, `OR`. Illegal XML characters must be properly encoded, and single quotes must be escaped with backslashes (`'Jane\'s Deli'`). Joins are not supported. | | |
| | pagesize | optional | integer | Custom page size between 1 and 1000 items (Default: 100). | | |
| | returnFormat | Optional | string | `xml`, `csv`, or `json` (Default: xml). | | |
| | callback | Optional | string | JavaScript callback function that receives the XML response returned by the server as parameter. | | |
| --- | |
| ## ip\_readMore | |
| Generates a `readMore` API call. | |
| ### Parameters | |
| | Name | Required | Type | Description | | |
| | --- | --- | --- | --- | | |
| | object | Required | string | Object name of the object. | | |
| | callback | Optional | string | JavaScript callback function that receives the XML response returned by the server as parameter. | | |
| --- | |
| ## ip\_readRelated | |
| Generates a `readRelated` API call. | |
| ### Parameters | |
| | Name | Required | Type | Description | | |
| | --- | --- | --- | --- | | |
| | object | Required | string | Object name of the object. | | |
| | keys | Required | string | Comma-separated list of keys of the records from which related objects are found. | | |
| | relation | Required | string | Name of the relation to follow from the given record(s). | | |
| | fields | Required | string | Comma-separated list of fields or \* for all. | | |
| | returnFormat | Optional | string | `xml`, `csv`, or `json` (Default: xml). | | |
| | callback | Optional | string | JavaScript callback function that receives the XML response returned by the server as parameter. | | |
| --- | |
| ## ip\_readView | |
| Generates a `readView` API call. This call typically relies on filters set in the view through the Sage Intacct UI, but you can set additional filters to incorporate dynamic information generated by your script. | |
| > Uses a filter: | |
| ```xml | |
| var api = new API_Session(); | |
| var invoiceRecNo = "{!ARINVOICE.RECORDNO#text!}"; | |
| var arr = {"filterExpression" : {"field":"RARINVOICE", "operator":'is one of', "value":invoiceRecNo}}; | |
| api.ip_readView('collection_activity#147115@10570', arr, 100, 'json', function(data) { | |
| alert(api.ip_getLastRequest()); | |
| displaySearchResults(data); | |
| }); | |
| </script> | |
| ``` | |
| ### Parameters | |
| | Name | Required | Type | Description | | |
| | --- | --- | --- | --- | | |
| | view | Required | string | Expressed as `object#viewOriginalID` . | | |
| | filters | Optional | string | Expressed as `{"filterExpression" : {"field":"FIELD_NAME", "operator":"OPERATOR TEXT", "value":"VALUE"}}`, max 5 filter conditions . | | |
| | pagesize | Optional | integer | Custom page size between 1 and 1000 items (Default: 100). | | |
| | returnFormat | Optional | string | `xml`, `csv`, or `json` (Default: xml). | | |
| | callback | Optional | string | JavaScript callback function that receives the XML response returned by the server as parameter. | | |
| --- | |
| ## ip\_update | |
| Generates an `update` API call. | |
| > Shows an update operation: | |
| ```xml | |
| var id = '{!object.id!}'; // Id of the current record of the object to update | |
| var fmv = '{!object.test_field!}'; | |
| var s = new API_Session(); | |
| var arr = {"id":id, "test_field":fmv}; | |
| s.ip_update('object', arr); | |
| </script> | |
| ``` | |
| ### Parameters | |
| | Name | Required | Type | Description | | |
| | --- | --- | --- | --- | | |
| | object | Required | string | Object name of the object. | | |
| | fieldsArray | Required | string | JSON array of fields: `"field name":field value` . | | |
| | callback | Optional | string | JavaScript callback function that receives the XML response returned by the server as parameter. | | |
| --- | |
| ## ip\_updateXML | |
| Generates an `update` API call using XML content that you provide. | |
| ### Parameters | |
| | Name | Required | Type | Description | | |
| | --- | --- | --- | --- | | |
| | xmlPayload | Required | string | XML text, which may include multiple objects to create. Provide the XML elements that go between `<update></update>` in the XML API `update` function as the payload. | | |
| --- | |
| Provide feedback | |
Xet Storage Details
- Size:
- 10.3 kB
- Xet hash:
- b71a283197dd88a3bc0b9d116b00d80ae7986845d81ef6ed798199d6d3a19189
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.