Loading
Servicio de mensajes Lightning para componentes de la interfaz de usuario de configurador externo

Servicio de mensajes Lightning para componentes de la interfaz de usuario de configurador externo

Utilice eventos de Servicio de mensajes Lightning (LMS) para permitir que un componente externo se comunique con el componente Gestor de datos en el flujo del configurador de productos. Agregue eventos LMS al archivo JavaScript para que el componente envíe y reciba datos.

Ediciones necesarias

Disponible en: Lightning Experience
Disponible en: Ediciones Enterprise, Unlimited y Developer de Gestión de ingresos (anteriormente Revenue Cloud) con la licencia Revenue Cloud Growth o la licencia Revenue Cloud Advanced

Este ejemplo muestra eventos LMS disponibles.

export const LMS_EVENTS = Object.freeze({
    VALUE_CHANGE: "valueChanged",
    NAVIGATE: "navigate",
    CLOSE_PREVIEW: "closePreview",
    TOGGLE_INSTANT_PRICING: "toggleInstantPricing",
    TOGGLE_RULES_VALIDATION: "toggleRulesValidation",
    TOGGLE_COMPACT_LAYOUT: "toggleCompactLayout",
    UPDATE_PRICES: "updatePrices",
    VALIDATE_PRODUCT: "validateProduct",
    CLONE_ITEMS: "cloneItems",
});

Puede utilizar eventos LMS para actualizar campos, incluyendo campos de elemento de transacción de ventas, selección y atributo. Los eventos LMS pueden actualizar todos los campos, tanto estándar como personalizados, que están configurados como modificables en un elemento de transacción de ventas. Un evento LMS no puede actualizar un campo de solo lectura.

Para actualizar un campo, pase el nombre del atributo del campo y el nuevo valor, como se muestra aquí.

{
key: ["0QLxx0000004jGGGAY"],
field: "SalesTrxnItemDescription"
value: "Updated description"
}

Este ejemplo muestra una selección de campos modificables.

export const STATE_FIELDS = Object.freeze({
    IS_SELECTED: "isSelected",
    QUANTITY: "Quantity",
    ATTRIBUTE_FIELD: "AttributeField",
    PRODUCT_SELLING_MODEL: "ProductSellingModel",
    PRICING_TERM_UNIT: "PricingTermUnit",
    SUBSCRIPTION_TERM: "SubscriptionTerm",
    SELLING_MODEL_TYPE: "SellingModelType",
    PRICE_BOOK_ENTRY: "PricebookEntry",
    IS_DELETED: "Deleted",
    UNIT_PRICE: "UnitPrice",
    CUSTOM_PRODUCT_NAME: "CustomProductName"
    CUSTOM_FIELD_NAME: “New Value for Custom Field”
});

Este ejemplo muestra la carga del evento de valueChanged.

Nota
Nota Para campos personalizados, utilice este formato de carga en lugar del formato estándar:
{
action: LMS_EVENTS.VALUE_CHANGE,
data: [
{
key: ["<id>"],
values: [
{
field: <field api name>,
value: <value>,
}
]
}
]
}
const bulkMessagePayload = {
    action: LMS_EVENTS.VALUE_CHANGE,
    data: [
        // Change 1: update the root product's quantity field
        {
            key: ["0QLxx0000004jGGGAY"],
            field: STATE_FIELDS.QUANTITY,
            value: 100
        },
        // Change 2: update the root product's attribute
        {
            key: ["0QLxx0000004jGGGAY"],
            field: STATE_FIELDS.ATTRIBUTE_FIELD,
            attributeId: "0tjxx0000000001AAA",
            value: "New Value"
        },
        // Change 3: update another one of root product's attributes
        {
            key: ["0QLxx0000004jGGGAY"],
            field: STATE_FIELDS.ATTRIBUTE_FIELD,
            attributeId: "0tjxx0000000001AAB",
            value: "0xxxx0000000001AAB"
        },
        // Change 4: create a picklist attribute that does not exist (non-defaulted picklist)
        {
            key: ["0QLxx0000004jGGGAY"],
            field: STATE_FIELDS.ATTRIBUTE_FIELD,
            attributeId: "0tjxx0000000001AAC",
            value: "0xxxx0000000001AAB"
        },
        // Change 5: select a static child product
        {
            key: ["0QLxx0000004jGGGAY"],
            productRelatedComponentId: '0dSxx00000000XtEAI', // the static child PRC to select
            field: STATE_FIELDS.IS_SELECTED,
            value: true
        },
        // Change 6: select a dynamic option with a child option below it
        {
            field: STATE_FIELDS.IS_SELECTED,
            selectedDynamicOptions: dynamicOptionsForInputPayload,
            productRelatedComponent: prcForInputPayload
        },
        // Change 7: change the PSM for the root product from onetime to termed
        {
            key: ["0QLxx0000004jGGGAY"],
            field: STATE_FIELDS.PRODUCT_SELLING_MODEL,
            value: {
                psmId: "0jPxx00000002JZEAX",
                pbeId: "01uxx000000A0tKAAX"
            }
        },
        // Change 8: deselect a child static option
        {
            key: ["0QLxx0000004jGGGAY", '0QLxx0000004jGHGAY'],
            field: STATE_FIELDS.IS_SELECTED,
            value: false
        }
    ]
};

publish(MessageContext, MessageChannel, bulkMessagePayload);
 
Cargando
Salesforce Help | Article