Set Outlook category for saved items via LWC#

You can configure your Lightning web component (LWC) to automatically assign an Outlook “Salesforce” category to emails and events saved through Context Panel.

This provides a clear visual indicator in Outlook that the item has been successfully tracked in Salesforce.

Before you begin#

Ensure the following:

  • The Lightning web component (LWC) is integrated with Context Panel and used as the save experience.

How it works#

The Outlook category is applied by Context Panel after the component completes a successful save operation.

The flow is as follows:

  1. The user saves an email or event through Context Panel with the integrated LWC.

  2. The component creates or updates the Salesforce record.

  3. The component dispatches the rg:finish event with the setCategory parameter set to true.

  4. Context Panel applies the configured Outlook category to the item.

The category is applied only if the save operation completes successfully. If the save fails or is canceled, the category is not applied.

Configure category assignment#

To enable automatic category assignment, include the setCategory parameter in the rg:finish event.

If your component already dispatches the rg:finish event (for example, to pass linkedAttachments or other parameters), add setCategory: true to the existing event payload. You do not need to create a separate event.

If the event is not yet implemented, follow the steps below.

setCategory parameter#

setCategory is a boolean flag that controls whether Context Panel applies the configured Outlook category to the current email or event after a successful save.

  • If set to true, the category is applied.

  • If set to false or not specified, the category is not applied.

Step 1. Define event parameters#

Define the setCategory parameter in the event payload.

var finishEventParams = {
    setCategory: true
};

Step 2. Create the event#

Create a CustomEvent with the name rg:finish and pass the parameters in the detail object.

var finishEvent = new CustomEvent("rg:finish", {
    detail: finishEventParams
});

Important

Do not change the rg:finish event name. Context Panel listens for this exact event.

Step 3. Dispatch the event#

Dispatch the event after the save operation is completed.

this.dispatchEvent(finishEvent);

Once dispatched, Context Panel applies the configured Outlook category to the item.

(optional) Combine with other rg:finish parameters#

You can use setCategory together with other rg:finish parameters in the same event.

Common examples include:

  • notificationMessage to show a custom success message

  • createdActivityIds or createdObjectIds to enable the View it now action

  • reloadActivities to refresh the activity state in the Context Panel

  • reloadResolvedObjects to refresh resolved objects

Example:

var finishEventParams = {
    notificationMessage: "Email was saved to Salesforce.",
    createdActivityIds: ["02sXXXXXXXXXXXXXXX"],
    reloadActivities: true,
    reloadResolvedObjects: true,
    setCategory: true
};

For the complete list of rg:finish parameters, see the article rg:finish event parameters.

Deployment#

After updating the component, deploy it to your Salesforce organization.