Technical¶
Included Components¶
ACD consists of these parts:
- Frontend with Lime Web Components (in webclient)
- Frontend with Lime Bootstrap (in desktop client)
- Python endpoints
- Scheduled task for automatic updates
- Possibility to use in custom flow
1. Frontend - Web Client¶
ACD for the web client is built on Lime Web Components interfaces which provide an API and component life cycle management for the web client. More information can be found here: Lime Web Components. Most of the elements used in ACD are Lime Elements. More information about Lime Elements can be found here: Lime Elements
2. Frontend - Desktop client¶
The desktop app is created with Lime Bootstrap but aims to mimic the look and feel of the web client component. Since Lime Bootstrap doesn't offer the same component based approach as Lime Web Components, it consists of two separate apps as described below.
ACD Modal¶
The app for searching and acquiring companies. A dialog is shown from VBA with the app inside it. From the app the user can also decide to instead create a company manually, i.e., the "normal" way in Lime CRM.
ACD¶
A app living in the actionpad of the company inspector. If the company is synced with the data provider (it has a provider id) the app will show. The app shows what data provider that is the source, as well as when the company was last synced from the data provider. A button to refresh the company's data is available.
3. Python Endpoints¶
CompanyEndpoint - POST¶
/company/
Fetch company from configured data source by source ID and create a CRM company. If a limeid
is provided, the corresponding CRM company will be updated. It will return the created/updated Lime CRM company id.
Example json payload:
```json
{
"sourceid": "115:11111111",
"limeid": 1002 // Optional
}
```
Example response:
```json
{
"id": 1002
}
```
Search - GET¶
/search/
Search for companies in the configured data provider and map them to a Lime CRM company if possible. Different data providers allows for different search opportunities.
Example json payload for dnbbc as a data provider:
```json
{
"query": {
"searchText": "Lime technologies",
"onlyActiveCompanies": false,
"onlyHeadOffices": true
}
}
```
Note
The query value should be a JSON string.
Example response (tuple with search result and the number of total search hits):
```tuple
([{"name": "Lime technologies", "city": "Lund", "country": "SE"}], 1)
```
CreditsafeCountries - GET¶
/creditsafe/countries/
Returns available countries in your Creditsafe subscription.
Example response:
```json
[
{
"text": "Sweden",
"value": "SE",
"selected": true | false
}
]
```
MetaData - GET¶
/meta-data/
Serves the dekstop app with translations and config values. This endpoint takes no input data.
Example response:
```json
{
"config": {"provider": "dnbbc", ... },
"translations": {"title": "Add company", ... }
}
```
The configuration dict is filtered, all configuration values is not included, only the ones that is needed.
The translation dict only includes translations related to this add-on and the language is the same as the current session's. If the current language is not supported, English is returned.
4. Scheduled Task for Automatic Updates¶
If enabled in the application config the scheduled task will fetch updates from the provider's API every night. The task will go through the following steps:
- Check if automatic updates is supported for the configured provider
- Request the latest changes from the provider and map the response to valid limeobjects. Check out the "How it works" page of a provider to read up on provider specific details.
- Save all changes to the Lime database. The provider id dictates which limeobject will be updated.
5. Possibility to Use in Custom Flow¶
From version 8.3.0 of the package you're able to use the ACD in your custom flow. You can open the search dialog and get an event back with the created/selected Id.
This is done in a few steps:
-
Add imports to your component
```typescript import { CreateLimeobjectDialogCommand, SaveLimeObjectCommand, } from "@limetech/lime-web-components-commands"; import { CommandBusService, CommandEvent, EventDispatcherService, getCommandId, PlatformServiceName, } from "@limetech/lime-web-components-interfaces"; ```
-
Open ACD Dialog
Put this function in your component
```typescript private openAcdDialog = () => { const createCommand: CreateLimeobjectDialogCommand & { formData?: object; } = new CreateLimeobjectDialogCommand(); // If the command should route to the newly company or not createCommand.route = false; createCommand.context = this.context; // Make sure to fetch the companyLimetype using @Limetypes decorator createCommand.limetype = this.companyLimetype; createCommand.formData = { searchText: 'Value to search for automatically', }; // Values to fill if creating company manually createCommand.limeobject = { name: 'My new company...', }; const commandBus: CommandBusService = this.platform.get( PlatformServiceName.CommandBus ); commandBus.handle(createCommand); } ```
-
Create event listeners for when company is selected/created
Put these in your component
```typescript private acdCompanySelected = (event: CustomEvent<{ limeId: number }>) => { const companyId = event.detail?.limeId; console.log("ACD added company", companyId); }; private manuallyCompanyCreated = ( event: CustomEvent<{ command: SaveLimeObjectCommand; result: { _id: number }; }> ) => { const command = event.detail?.command; if (getCommandId(SaveLimeObjectCommand) !== getCommandId(command)) { return; } if (command.limeobject.getLimetype().name !== this.companyLimetype.name) { return; } const result = event.detail?.result; // eslint-disable-next-line no-underscore-dangle console.log('Saved company with id', result?._id); }; ```
-
Add/Remove event listeners
Put these functions in your component
Functions may already exist
If the function already exists, put this first in the function
public disconnectedCallback() { this.eventDispatcherService.removeListener( 'addon_acd-company-selected', this.acdCompanySelected ); this.eventDispatcherService.removeListener( CommandEvent.Handled, this.manuallyCompanyCreated ); } public componentWillLoad() { this.eventDispatcherService.addListener( 'addon_acd-company-selected', this.acdCompanySelected ); this.eventDispatcherService.addListener( CommandEvent.Handled, this.manuallyCompanyCreated ); }
Miscellaneous Provider Specific Info¶
Dun & Bradstreet Business Contacts¶
Using the search API is free. It is when you do a GET on a specific company/worksite/person that Dun & Bradstreet counts it as a purchase. Updating a company in Lime CRM that you already have bought from Dun & Bradstreet is counted as a subscription, which has a lower price per ID. That price is paid per year, which means you can do several updates during a year for the same cost as one update.