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

    Type Alias LimeObjectConditionBeta

    LimeObjectCondition: Condition<LimeObject> & { type: "limeobject" }

    A specialized condition type for evaluating LimeObject instances.

    LimeObject conditions are the most common type of condition, used to control UI elements based on the state of business objects (deals, contacts, companies, etc.). The evaluate function receives a LimeObject and can check any of its properties to determine if the condition is met.

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

    const registry = platform.get(PlatformServiceName.ConditionRegistry);

    const isDealActive: LimeObjectCondition = {
    id: 'deal.is-active',
    type: 'limeobject',
    evaluate: (deal) => {
    const status = deal.getValue('dealstatus');

    return status === 'qualification' || status === 'proposal';
    },
    };

    registry.addCondition(isDealActive);

    const repository = platform.get(PlatformServiceName.LimeObjectRepository);
    const deal = repository.getObject('deal', 1234);

    const condition = registry.getCondition('deal.is-active');
    const isActive = !!deal && condition.evaluate(deal);
    import {
    Action,
    Command,
    LimeObjectCondition,
    } from '@limetech/lime-web-components';

    @Command({ id: 'send-email' })
    class SendEmailCommand {
    to: string;
    }

    const canSendEmail: LimeObjectCondition = {
    id: 'contact.can-send-email',
    type: 'limeobject',
    evaluate: (contact) => {
    const email = contact.getValue('email');

    return typeof email === 'string' && email.length > 0;
    },
    };

    const sendEmailAction: Action = {
    label: 'Send Email',
    icon: 'envelope',
    command: new SendEmailCommand(),
    condition: canSendEmail,
    };

    Use a RulePrimitive that declares reads: ['limeobject'] directly, rather than a typed condition.