API ForeignKeys

Integrate external resources into Labii by fetching data from an API URL and displaying it as a dropdown menu

Specs

Label
Value

Version

0.1.0 (updated on 2025-02-11)

Developer

Labii Inc.

Type

Column

Support Configuration

Yes

Support Readonly view

Yes

Support Edit view

Yes

Support Form view

Yes

Support Default value

Yes

Support Import

Yes

Allow multiple

Yes

Overview

The Labii API ForeignKeys Widget extends the functionality of the API ForeignKey Widget by allowing users to select multiple options from an API-fetched dropdown list. Like the API ForeignKey Widget, it dynamically retrieves data from a specified API URL, enabling seamless integration of external resources into Labii. This widget is ideal for workflows that require linking multiple external references to a single record, providing greater flexibility and efficiency in managing interconnected data within Labii.

Use case

  • Display lot numbers of potential orders from 3rd party vendor.

Configuration

To enable the widget's functionality, it requires the provision of options.

  • Bearer Token - Bearer Token or any other authorization string. Bearer Tokens are the predominant type of access token used with OAuth 2.0. For example: Bearer eyJraWQiOiIy

  • URL - The URL to download list of items.

  • Search Prefix - The prefix to search for list of items. Default to empty.

  • Method - The API method to download list of items. Default to GET.

  • Results Key - The key to extract results from the API response. Default to results.

  • SID Key - The key to extract SID/ID from the API response. Default to id.

  • Name Key - The key to extract Name from the API response. Default to name.

  • Link - Link to the detail page of the record. Use {SID} to replace with the record's sid/id.

Example

{
    "url": "http://127.0.0.1:8080/vendors/",
    "method": "get",
    "sid_key": "id",
    "name_key": "name",
    "results_key": "results",
    "authorization": "Bearer xxx",
    "search_prefix": "name__icontains"
}

Views

See the interface of the widget in the following views.

Readonly view

Readonly view display the values of the column.

Edit view

The Edit view is the interface that allows you to modify the value.

Edit view is not supported for this widget.

Form view

The Form view is the field integrated into the add form for collecting values when creating a new record.

Form view is identical to the Edit view.

Data

Each widget in Labii stores data in a unique manner; refer below to understand how data from this widget is stored.

Data format

JSON object with the keys of sid and name.

{"sid": "", "name": ""}

Default value

The Default Value field within the column allows you to specify the default value when a record is created.

Default value shall be json object with keys of sid and name.

Import value

The Import Value is the value you need to include in your Excel table for it to be imported into Labii.

Import value shall be json object with keys of sid and name.

Last updated