General
To activate an app as a data source, turn on the Data source toggle under Frameworks. Then, continue to configure the app as specified by the documentation below. For a full example of how the config may look see Figure 1. For general app configuration, e.g. user configurable fields, see Upsales app documentation.
Upsales sends every request to your app as a POST with a JSON body, and your app endpoint must use HTTPS. Your app has 30 seconds to respond.
Capabilities config
The following fields can be configured under capabilities. Your app is listed in the add new company modal only if capabilities.typeahead is set, and in the update/connect company dialog only if capabilities.refresh is set.
Table 1
Properties for the capabilities config object
| Property | Valid values | Example | Description |
| logo | String | "https://img.upsales.com/app/102/logo.png" | Used to render the logo of the app in the add new company modal and the update/connect company dialog. If not set, the add new company modal uses the app's icon. |
| match | Object | {"upsales": "dunsNo", "integration": "dunsNo"} | Used to determine if a company already exists in Upsales. |
| pricing | Object of pricing options, see Table 2 for properties | {"buy": {"endpoint": "buy", "cost": 0, "text": "Basic data"}} | The buy options shown when a user presses the add button. Each key is one option and must be "buy" or "monitor". With more than one option, the user picks one before confirming. If pricing is not set, the add button adds the company directly. |
| typeahead | Object, see Typeahead config | {"idField": "dunsNo", "columns": [...]} | Configuration for the add new company modal. |
| refresh | Object, see Refresh config | {"columns": [...]} | Configuration for the update/connect company dialog. |
Table 2
Properties for a pricing option
| Property | Valid values | Example | Description |
| endpoint | "buy" or "monitor", the same as the option's key | "buy" | The request Upsales sends to your app when the user confirms this option: /client/buy or /client/monitor. |
| text | String, or object with a text per language code | {"en": "Basic data", "sv": "Basdata"} | The name of the option. With an object, the text for the user's language is shown, with English as fallback. |
| cost | Number | 10 | Shown under the option as a number of credits. |
Typeahead config
This is the configuration for the add new company modal. Each search is sent to your app as a filter on name, or on orgNo when the search text looks like an organisation number. The following fields can be configured under typeahead:
Table 3
Properties for the typeahead config object
| Property | Valid values | Example | Description |
| idField | String | "duns_no" | When a user press buy on a row, the value from this field of that object will be sent to the app via {body: {data: {id}}} |
| pagination | Object, see Table 4. for properties | {"enabled": false} | Option object for enabling/disabling pagination |
| countryTabs | Object, see Table 5. for properties | {"enabled": true, "showAll": false, "showTotals": false} | Option object for enabling/disabling country tabs |
| columns | Array of Column, See Table 6. for Column properties | {"type": "add", "width": "30%"} | An array of Column config objects, determine how the result table will look |
| waitTime | Number | 500 | How many milliseconds to wait after the user stops typing before searching. Default is 300. |
Table 4
Properties for the pagination config object
| Property | Valid values | Example | Description |
| enabled | Boolean | true | This enables/disables pagination in the case when metadata.total > data.length |
Table 5
Properties for the countryTabs config object
| Property | Valid values | Example | Description |
| enabled | Boolean | true | This enables/disables countryTabs, if disabled the typeahead will send any country filter or country list. |
| showAll | Boolean | true | This enables/disables the "All" tab when using country tabs. |
| showTotals | Boolean | true | This enables the tags that show the total amount of matching companies for each result. |
Columns
The following attributes can be configured for columns
Table 6
Properties for a Column config object
| Property | Valid values | Example | Description |
| type | String | "string" | The type decides the behavior and presentation of the column. For the most part, the type only decides how to present the value of the field, e.g. "currency", but the "add", "user" and "view" types are special types that come with set behaviors attached to them. See Table 7 for valid values. |
| header | String | "Company name" | This is the name of the column. |
| width | String | "25%" | The width of the column in %. |
| field | String | "name" | The field on the object from which the value should be picked. |
| subText | Array of Column | {"type": "string", "field": "name"} | This adds a second row to the column. The config object is the same as a column with the exception that the following attributes have no effect: width, header, subText. |
| icon | String | "fa fa-bar-chart" | This enables one to put an icon in front of the value. |
| style | React style object | {"marginRight": "5px"} | This allows one to pass any CSS style to the TD element of the column |
| staticValue | String | "sniCode" | This allows for translations of "staticValues" that exists in Upsales, e.g. sniCode. |
Table 7
The different types of columns
| Value | Description |
| number | This type will parseInt() the value before rendering it. |
| string | This type will just render the value as is. |
| currency | This type will render a number thousand separated. |
| flag | This type will render a flag if provided with a country code e.g. 'SE' |
| add | This type will show the add/merge buttons. It uses the pricing object under capabilities to generate the different buy options, see Table 2. |
| user | This type will render gravatars for users under the user attribute on the object if they are formatted in the same way as for Upsales companies. |
| view | This type will use the idField to navigate to /accounts/{id}/ |
Refresh config
This is the options for the update/connect company button in the company view. The following fields can be configured under refresh:
| Property | Valid values | Example | Description |
| columns | Array of Column | {"type": "string", "field": "name"} | Same as for typeahead |
iFrame configuration
To show your app in an iframe on the company card, set iframe=true in the outermost layer of the config. The app's icon is shown next to its name. When a user opens the app on a company, Upsales sends a POST request to your app on /iframe with the company under body.data (its id is body.data.id). Respond with the URL of the page to show in the iframe.
Example
Figure 1. An example config for a data source app
{
"fields": {
"account": [
{
"type": "multiselect",
"name": "countries",
"label": "Countries",
"required": true,
"externalValues": true
},
{
"type": "checkbox",
"name": "createContacts",
"label": "Create contacts"
}
],
"user": [],
"test": true
},
"uiElements": {
"account": {
"sidebar": [
{
"name": "monitoring",
"type": "iframe"
}
]
}
},
"requirements": [],
"capabilities": {
"logo": "https://img.upsales.com/app/102/logo.png",
"match": {
"upsales": "dunsNo",
"integration": "dunsNo"
},
"pricing": {
"buy": {
"endpoint": "buy",
"cost": 0,
"text": {
"en": "Basic data",
"sv": "Basdata"
}
}
},
"typeahead": {
"idField": "dunsNo",
"pagination": {
"enabled": true
},
"countryTabs": {
"enabled": false
},
"columns": [
{
"type": "string",
"header": "Company name",
"field": "name",
"width": "70%"
},
{
"type": "add",
"width": "30%"
}
]
},
"refresh": {
"columns": [
{
"type": "string",
"header": "Company name",
"field": "name",
"width": "70%"
},
{
"type": "add",
"width": "30%"
}
]
}
},
"iframe": true
}