Describes the context in which a Lime Web Component is running.

The context provides information about the current business object (limetype and ID) that the component is associated with. This allows components to load and interact with the relevant data based on where they are displayed in the application.

Contexts can be nested when components are embedded within other components, allowing for hierarchical relationships between different views.

Example

// Component running in a customer detail view
const context: LimeWebComponentContext = {
limetype: 'customer',
id: 12345
};

// Component on a list view (no specific record)
const listContext: LimeWebComponentContext = {
limetype: 'customer',
id: null
};

// Nested context - contact list within a customer view
const nestedContext: LimeWebComponentContext = {
limetype: 'contact',
id: null,
parent: {
limetype: 'customer',
id: 12345
}
};

Example

// Load related data based on parent context
const repo = platform.get(PlatformServiceName.LimeObjectRepository);

if (context.parent?.limetype === 'customer' && context.parent.id) {
const result = await repo.loadObjects('contact', {
filter: {
key: 'customer',
op: '=',
exp: context.parent.id
}
});
}

Hierarchy

  • LimeWebComponentContext

Properties

Properties

id: number

The ID of the specific limeobject (record) in this context.

When set, indicates the component is viewing/editing a specific record. When null, the component may be on a list view or creating a new record.

Example

if (context.id) {
// Load and display the specific record
const object = await repo.loadObject(context.limetype, context.id);
} else {
// Show list view or new record form
}
limetype: string

The name of the LimeType for this context.

This identifies what type of business object the component is working with (e.g., 'customer', 'contact', 'deal', 'invoice'). Can be null if the component is not associated with a specific limetype.

Example

if (context.limetype === 'customer') {
// Load customer-specific data and features
}

Optional parent context when this component is nested within another.

Used when components are embedded in other components to maintain the relationship hierarchy. For example, a contact list component shown within a customer detail view would have the customer as its parent context.

Example

// Check if running within another context
if (context.parent) {
console.log(`Nested within ${context.parent.limetype}`);

// Load data filtered by parent
if (context.parent.id) {
const relatedRecords = await loadRelatedToParent(context.parent);
}
}