Auth
These methods are specifically used in the authentication code block.
| Method | Parameters | Return | Description |
|---|---|---|---|
| auth.authenticationSuccess() | none | none | Set during the authentication process to indicate that the credentials have been successfully validated. |
| auth.authenticationFailed(errorMessage) | errorMessage | none | Set during the authentication process to indicate that the credentials could not be validated. |
Datagrid
Domo provides methods and constants to help you insert your data into Domo. These methods and constants are specifically used in the data processing code block. These constants are used to define the data type of a column in a datagrid.
| Name | Description |
| datagrid.DATA_TYPE_STRING | Set a column dataType to receive a string. |
| datagrid.DATA_TYPE_DOUBLE | Set a column dataType to receive a number. |
| datagrid.DATA_TYPE_DATETIME | Set a column dataType to receive a date/time. Dates inserted into the table need to be formatted yyyy-MM-dd’T’HH:mm:ss. |
| datagrid.DATA_TYPE_DATE | Set a column dataType to receive a date. Dates inserted into the table need to be formatted yyyy-MM-dd. |
| Method | Parameters | Return | Description |
| datagrid.addColumn(columnName, dataType) | columnName, dataType | none | Adds a column to a table. Defines the data type used by the column. |
| datagrid.addCell(cellData) | cellData | none | Adds data to one cell in the table. Columns must be defined first. |
| datagrid.endRow() | none | none | Indicates a row of data is complete and a new row in the table needs to be started. |
| datagrid.error(code, errorMessage) | code, errorMessage | none | Ends the processing of data and returns an error message to the user. |
| datagrid.magicParseCSV(csvString) | csvString | none | Populates the entire datagrid when passed a properly formatted string of comma-separated values. |
| datagrid.magicParseJSON(jsonString) | jsonString | none | Populates the entire datagrid when passed a string representation of properly formatted JSON. |
| datagrid.magicParseXML(xmlString) | xmlString | none | Populates the entire datagrid when passed a string representation of properly formatted XML. |
Discovery
If you are using the Discovery option in Advanced Mode in the Configure Reports step, Domo provides methods and constants to help you. These methods and constants are specifically used in the discovery code block. This constant is used when building a discovery tree menu.
| Name | Description |
| discovery.tree | Used with a discovery tree. This references the root node in a discovery tree. |
| Method | Parameters | Return | Description |
| discovery.addOption(optionValue) | optionValue | none | Used with a discovery dropdown. Adds an option to the dropdown menu. |
| discovery.addOption(optionName,optionValue) | optionName, optionValue | none | Used with a discovery dropdown. Adds an option to the dropdown menu. Option name appears as label, option value is used in the code. |
| discovery.addNode(parentNode, nodeName) | parentNode, nodeName | createdNode | Used with a discovery tree. Creates a new child node within the node that is passed as a parameter. Returns a reference to the newly created node. |
| discovery.addLeaf(parentNode, leafName) | parentNode, leafName | none | Used with a discovery tree. Creates a new child leaf within the node that is passed as a parameter. |
| discovery.publishTree() | none | none | Used with a discovery tree. This method indicates that you have finished constructing a discovery tree. |
Domo
These methods may be useful in any code block.
| Method | Parameters | Return | Description |
| DOMO.log(value) | value | none | Prints to the Dev Studio console. Make sure you remove any credentials that you are logging for testing before you submit your connector. |
| DOMO.sleep(milliseconds) | milliseconds | none | Can be used to space out HTTP requests. |
| DOMO.getState(key) | key | value | Returns the value of the requested state. |
| DOMO.setState(key, value) | key, value | none | Can be used to set a state value which can be returned using DOMO.getState(key). |
| DOMO.parseXML(xmlString) | xmlString | jsonObject | Used to convert XML to JSON for easier parsing. |
| DOMO.getStartDate(metadata.parameters[“Date”]) | Date | date | Used to set the start date. |
| DOMO.getEndDate(metadata.parameters[“Date”]) | Date | date | Used to set the end date. |
| Encoding Method | Parameters | Return | Description |
| DOMO.b64EncodeUnicode(stringToEncode) | stringToEncode | encodedString | Encodes a string using base64 encoding. |
| DOMO.b64DecodeUnicode(stringToDecode) | stringToDecode | decodedString | Decodes a string using base64 decoding. |
| DOMO.hmacSHA1(stringToEncode, key) | stringToEncode, key | encodedString | Encodes a string using the provided key to create a hmac-SHA1 hash. |
HTTP Request
When making your HTTP requests, use the following methods to add headers and parameters, and to make HTTP calls. Note: All URLs must use https.
| Method | Parameters | Return | Description |
| httprequest.addHeader(key, value) | key, value | none | Add a header to your HTTP request. This is how you can add an Authorization header or any other header you need to your HTTP request. Add headers and parameters before you make the HTTP request. |
| httprequest.addParameter(key, value) | key, value | none | Add a parameter to a base URL. Add headers and parameters before you make the HTTP request. |
| httprequest.clearParameters() | none | none | Remove any parameters you have added to an HTTP request object. |
| httprequest.clearHeaders() | none | none | Remove any headers you have added to an HTTP request object. |
| httprequest.getHeader(key) | key | headerValue | Get a string containing a particular header’s value from your HTTP request. If you have added headers using the httprequest.addHeader method, you can use this method to retrieve that value. |
| httprequest.getResponseHeader(key) | key | headerValue | Get the string containing a particular header’s value from your HTTP response. If there are multiple response headers with the same name, then their values are returned as a single concatenated string, where each value is separated by a pair of comma and space. |
| httprequest.getStatusCode() | none | responseCode | Get the HTTP response code from your HTTP request. After you make a httprequest.get, httprequest.post, or httprequest.post call, the HTTP response will have a number code. Usually 200 is used if the request has succeeded. For more information, see here. |
| httprequest.get(url) | url | responseString | Make an HTTP GET request. Any headers or parameters added before making the request will be included by Domo when making the get request. All URLs must use https. |
| httprequest.post(url) | url | responseString | Make an HTTP POST request without any request body. Any headers or parameters added before making the request will be included by Domo when making the post request. All URLs must use https. |
| httprequest.post(url, bodyString) | url, bodyString | responseString | Make an HTTP POST request with a request body. Any headers or parameters added before making the request will be included by Domo when making the post request. All URLs must use https. |
| httprequest.put(url, bodyString) | url, bodyString | responseString | Make an HTTP PUT request with a request body. Any headers or parameters added before making the request will be included by Domo when making the put request. All URLs must use https. |
Metadata
Information you may need to run your connector will be stored in a metadata JavaScript object. Access data from the metadata object in the same way you would access data from any JavaScript object.
Metadata object structure
Metadata access examples
SQL
These SQL methods are used in the data processing code block. They are specifically used in the cases that require the state to be saved between runs.
| Method | Parameters | Return | Description |
| sql.createTable(tableName, schema, (optional) addIfNotExists) | (tableName, schema, (optional) addIfNotExists) | none | Create a table and define its columns |
| sql.select(columns, from, (optional) where, (optional) useDistinct) | (columns, from, (optional) where, (optional) useDistinct) | jsonArray | Return columns from database table |
| sql.update(tableName, values, (optional) where) | (tableName, values, (optional) where) | none | Update values in a database table |
| sql.insert(table, values) | (table, values) | none | Insert values in a database table |
| sql.delete(tableName, (optional) where) | (tableName, (optional) where) | none | Delete values in a database table |
| sql.export() | none | none | Export the current state of the database |

AWS
These AWS methods are used specifically to create S3 AWS client, to put the content under the specified name at the defined path, and to get the content of the specified file at the defined path.
| Method | Parameters | Return | Description |
| aws.createClient(region, key, secret) | (region, key, secret) | none | Creates an AWS S3 client |
| aws.put(path, name, value) | (path, name, value) | none | Puts the value content under the specified name at the defined path |
| aws.get(path, name) | (path, name) | String | Gets the content of the named file at the defined path |
Examples
Method Details
Auth Methods
These methods are specifically used in the authentication code block.auth.authenticationSuccess()
Set during the authentication process to indicate that the credentials have been successfully validated.Parameters:
- None
Returns:
- None
auth.authenticationFailed(errorMessage)
Set during the authentication process to indicate that the credentials could not be validated.Parameters:
- errorMessage: Message indicating why the authentication failed.
Returns:
- None
Datagrid Constants
These constants are specifically used in the data processing code block to define the type of your data in each of your datagrid columns.
datagrid.DATA_TYPE_STRING
Set a column dataType to receive a string. Example:datagrid.DATA_TYPE_DOUBLE
Set a column dataType to receive a number. Example:datagrid.DATA_TYPE_DATETIME
Set a column dataType to receive a string. Dates inserted into the table need to be formatted yyyy-MM-dd’T’HH:mm:ss. Example:datagrid.DATA_TYPE_DATE
Set a column dataType to receive a string. Dates inserted into the table need to be formatted yyyy-MM-dd Example:Datagrid Methods
These methods are specifically used in the data processing code block to insert your data into Domo.datagrid.addColumn(columnName, dataType)
Adds a column to a table. Defines the data type used by the column.Parameters:
- columnName: The column name that the user will see when they look at the table.
- dataType: The Domo data type. It may be datagrid.DATA_TYPE_STRING, datagrid.DATA_TYPE_DOUBLE, datagrid.DATA_TYPE_DATETIME, or datagrid.DATA_TYPE_DATE.
Returns:
- None
datagrid.addCell(cellData)
Adds data to one cell in the table. Columns must be defined first.Parameters:
- cellData: The datum to be inserted into this table cell. The type of the data should match the type in the column.
Returns:
- None
datagrid.endRow()
Indicates a row of data is complete and a new row in the table needs to be started.Parameters:
- None
Returns:
- None
datagrid.error(code, errorMessage)
Ends the processing of data and returns an error message to the user.Parameters:
- code: A integer code you would like to use to define the error.
- errorMessage: An error message that will be returned to the user.
Returns:
- None
datagrid.magicParseCSV(csvString)
Populates the entire datagrid when passed a properly formatted string of comma-separated values. The magicParse automatically determines type, and leaves any undetermined types as strings.Parameters:
- csvString: A string containing a comma-separated values. The first line should contain the comma-separated column names.
Returns:
- None

datagrid.magicParseJSON(jsonString)
Populates the entire datagrid when passed a string representation of properly formatted JSON. The magicParse automatically determines type, and leaves any undetermined types as strings.Parameters:
- jsonString: A string representation of a properly formatted JSON. The magicParseJSON method only works for JSON table data presented in key/value pairs.
Returns:
- None

datagrid.magicParseXML(xmlString)
Populates the entire datagrid when passed a string representation of properly formatted XML. The magicParse automatically determines type, and leaves any undetermined types as strings.Parameters:
- xmlString: A string representation of a properly formatted XML.
Returns:
- None

Discovery Constants
This constant is used when building a discovery tree menu in the Configure Reports Advanced Mode.
discovery.tree
Used with a discovery tree. This references the root node in a discovery tree. Example:Discovery Methods
These methods are used when building a discovery tree or discovery dropdown in the Configure Reports Advanced Mode.
discovery.addOption(optionValue)
Used with a discovery dropdown. Adds an option to the dropdown menu.Parameters:
- optionValue: The value to be displayed in the dropdown menu.
Returns:
- None

discovery.addNode(parentNode, nodeName)
Used with a discovery tree. Creates a new child node within the node that is passed as a parameter. To create a node at the root level, you must use discovery.tree as the node parameter.Parameters:
- parentNode: An existing node object in the discovery tree.
- nodeName: The name displayed on the new node.
Returns:
- createdNode: A reference to the newly created node object.

discovery.addLeaf(parentNode, leafName)
Used with a discovery tree. Creates a new child leaf within the node that is passed as a parameter.Parameters:
- parentNode: An existing node object in the discovery tree.
- leafName: The name displayed on the new leaf.
Returns:
- None

discovery.publishTree()
Used with a discovery tree. This method indicates when you have finished constructing a discovery tree.Parameters:
- None
Returns:
- None
discovery.addOption()
Used with a discovery dropdown. Adds an option to the dropdown menu. Option name appears as label, option value is used in the code.Parameters:
- optionName, optionValue
Returns:
- None
Domo Methods
These methods may be useful in any code block.
DOMO.log(value)
Prints to the Dev Studio console. Make sure you remove any credentials that you are logging for testing before you submit your connector.Parameters:
- value: The value to print. In JavaScript, this can be a string, but it doesn’t have to be.
Returns:
- None
DOMO.sleep(milliseconds)
Can be used to space out http requests.Parameters:
- milliseconds: An integer value representing the number of milliseconds you want your connector to sleep.
Returns:
- None
DOMO.getState(key)
If you have set a state for your connector, this method returns the value of the requested state.Parameters:
- key: The key to the state.
Returns:
- value: The value stored with that key.
DOMO.setState(key, value)
If you need to set a state for your connector, this method can be used to set a state value which can be returned using DOMO.getState(key).Parameters:
- key: The key to the state.
- value: The value stored with that key.
Returns:
- None
DOMO.parseXML(xmlString)
Used to convert XML to JSON for easier parsing.Parameters:
- xmlString: The key to the state.
Returns:
- jsonObject: A JSON object.
DOMO.getStartDate(metadata.parameters[“Date”])
Used to set the start date.Parameters:
- Date: The start date.
Returns:
- Date
DOMO.getEndDate(metadata.parameters[“Date”])
Used to set the end date.Parameters:
- Date: The end date.
Returns:
- Date
Domo Encoding Methods
These methods may be useful in any code block to encode data.
DOMO.b64EncodeUnicode(stringToEncode)
Encodes a string using base64 encoding. Base64 encoding is used in the Basic Authentication process, and most endpoints that use username and password will use the Basic Authentication standard.Parameters:
- stringToEncode: The string you wish to encode with base-64 encoding.
Returns:
- encodedString: The base-64 encoded string.
DOMO.hmacSHA1(stringToEncode, key)
Encodes a string using the provided key to create a hmac-SHA1 hash.Parameters:
- stringToEncode: The string you wish to encode.
- key: The string used to create the hmac-SHA1 hash.
Returns:
- encodedString: The hmac-SHA1 encoded string.
DOMO.hmacSHA256(stringToEncode, key)
Encodes a string using the provided key to create a hmac-SHA256 hash.Parameters:
- stringToEncode: The string you wish to encode.
- key: The string used to create the hmac-SHA256 hash.
Returns:
- encodedString: The hmac-SHA256 encoded string.
DOMO.md5(stringToEncode)
Encodes a string with the md5 algorithm.Parameters:
- stringToEncode: The string you wish to encode with md5 encoding.
Returns:
- encodedString: The md5 encoded string.
DOMO.getJWT()
Creates a JSON web token (JWT) token using the assigned algorithm signed with the provided key. Note: You must set the algorithm, key, issuer, subject, expiration, and other claims. Supported algorithms: HS256, RS256, ES256Parameters:
- None
Returns:
- tokenString: The JWT token.
Domo Decoding Method
This method may be useful in any code block to decode data.
DOMO.b64DecodeUnicode(stringToDecode)
Decodes a string using base64 decoding. Base64 decoding is used in the Basic Authentication process, and most endpoints that use username and password will use the Basic Authentication standard.Parameters:
- stringToDecode: The string you wish to decode with base-64 decoding.
Returns:
- decodedString: The base-64 decoded string.
HTTP Request Methods
These methods may be useful in any code block. When making your HTTP requests, use the following methods to add headers and parameters, and to make HTTP calls. Note: All URLs must use https.
httprequest.addHeader(key, value)
Add a header to your HTTP request. This is how you can add an Authorization header or any other header you need to your HTTP request. Add headers and parameters before you make the HTTP request.Parameters:
- key: A string that is the header key.
- value: A string that is the header value.
Returns:
- None
httprequest.addParameter(key, value)
Add a parameter to a base URL. Add headers and parameters before you make the HTTP request.Parameters:
- key: A string that is the parameter key.
- value: A string that is the parameter value.
Returns:
- None
httprequest.clearParameters()
Remove all parameters you have added to an httprequest object.Parameters:
- None
Returns:
- None
httprequest.clearHeaders()
Remove all headers you have added to an httprequest object.Parameters:
- None
Returns:
- None
httprequest.getHeader(key)
Get a string containing a particular header’s value from your HTTP request. If you have added headers using the httprequest.addHeader method, you can use this method to retrieve that value.Parameters:
- key: A string that is the parameter key.
Returns:
- headerValue: A string that is the value associated with the provided key.
httprequest.getResponseHeader(key)
When you make an HTTP request, the response will usually include a header containing a set of key/value pairs. Use this method to get the string containing a particular header’s value from your HTTP response. If there are multiple response headers with the same name, then their values are returned as a single concatenated string, where each value is separated by a pair of comma and space.Parameters:
- key: A string that is the parameter key.
Returns:
- headerValue: A string that is the value associated with the provided key.
httprequest.getStatusCode()
Get the HTTP response code from your HTTP request. After you make a httprequest.get, httprequest.post, or httprequest.post call, the HTTP response will have a number code. Usually 200 is used if the request has succeeded. For more information, see here. You can use the response code to gracefully handle failed HTTP requests.Parameters:
- None
- responseCode: The status code that indicates whether your HTTP request has been successfully completed.
httprequest.get(url)
Make an http get request. Any headers or parameters added before making the request will be included by Domo when making the get request. Note: All URLs must use https.Parameters:
- url: The URL you would like to use to make an HTTP get request.
Returns:
- responseString: The response from the endpoint you called.
httprequest.post(url)
Make an HTTP post request without any request body. Any headers or parameters added before making the request will be included by Domo when making the post request. Note: All URLs must use https.Parameters:
- url: The URL you would like to use to make an HTTP post request.
Returns:
- responseString: The response from the endpoint you called.
httprequest.post(url, bodyString)
Make an HTTP post request with a request body. Any headers or parameters added before making the request will be included by Domo when making the post request. Note: All URLs must use https.Parameters:
- url: The URL you would like to use to make an HTTP post request.
- bodyString: The body of your HTTP post request.
Returns:
- responseString: The response from the endpoint you called.
httprequest.put(url, bodyString)
Make an HTTP put request with a request body. Any headers or parameters added before making the request will be included by Domo when making the put request. Note: All URLs must use https.Parameters:
- url: The URL you would like to use to make an HTTP get request.
- bodyString: The body of your HTTP post request.
Returns:
- responseString: The response from the endpoint you called.