Lime Web Components API Documentation - v7.4.0
    Preparing search index...

    Interface LimeWebComponentContext

    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.

    import { LimeWebComponentContext } from '@limetech/lime-web-components';

    // A component running in a customer detail view
    const detailContext: LimeWebComponentContext = {
    limetype: 'customer',
    id: 123,
    };

    // A component on a list view, with no specific record
    const listContext: LimeWebComponentContext = {
    limetype: 'customer',
    id: null,
    };

    // A contact list nested within a customer view
    const nestedContext: LimeWebComponentContext = {
    limetype: 'contact',
    id: null,
    parent: {
    limetype: 'customer',
    id: 123,
    },
    };
    import { Operator, PlatformServiceName } from '@limetech/lime-web-components';

    const repository = platform.get(PlatformServiceName.LimeObjectRepository);

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

    const contacts = response.objects;
    }
    interface LimeWebComponentContext {
        id: number | null;
        limetype: string | null;
        parent?: LimeWebComponentContext;
    }
    Index

    Properties

    Properties

    id: number | null

    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.

    import { PlatformServiceName } from '@limetech/lime-web-components';

    const repository = platform.get(PlatformServiceName.LimeObjectRepository);

    if (context.limetype && context.id) {
    const limeObject = await repository.loadObject(
    context.limetype,
    context.id
    );
    }
    limetype: string | null

    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.

    import { PlatformServiceName } from '@limetech/lime-web-components';

    if (context.limetype === 'customer') {
    // Load customer-specific data and features
    const limetypes = platform.get(PlatformServiceName.LimeTypeRepository);
    const customer = limetypes.getLimeType('customer');
    }

    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.

    import { PlatformServiceName } from '@limetech/lime-web-components';

    const loggerFactory = platform.get(PlatformServiceName.Logger);
    const logger = loggerFactory.createLogger('my-component');

    if (context.parent) {
    logger.debug('Running in a nested context', {
    current: context.limetype,
    parent: context.parent.limetype,
    });

    // Load the record the parent context points at
    if (context.parent.limetype && context.parent.id) {
    const repository = platform.get(
    PlatformServiceName.LimeObjectRepository
    );

    const parentObject = await repository.loadObject(
    context.parent.limetype,
    context.parent.id
    );
    }
    }