The independent daily for Salesforce admins, developers and architects

Curated by Abhinav (opens in a new tab)

Must-read

Choosing between HXL widgets and assistant rendering for AI tool results (opens in a new tab)

You will learn when to let an AI assistant render a Salesforce tool result and when to ship a Headless Experience Layer widget, and what a widget can and cannot show.

Why read this

The piece gives a worked approval-request example and the wiring needed for each assistant.

Let the assistant render

  • Answers exploratory questions
  • Layout can vary each run
  • Charts drawn from tool results
  • No build beyond the tool

Ship an HXL widget

  • Fixed field order and grouping
  • Buttons send decisions back
  • Built once for all assistants
  • No chart component in beta
Assistant rendering suits open questions; widgets suit fixed layouts

The article contrasts two ways of presenting a Salesforce action’s result to users of AI assistants. By default, the assistant reads a JSON tool result from an MCP server and decides for itself what to emphasize and how to lay it out. The Headless Experience Layer, part of the Headless Toolkit, lets you define an interface once as a structured widget that assistants such as Claude, ChatGPT and Slackbot render natively. HXL is currently in beta across Agentforce employee agents in Lightning Experience, ChatGPT, Claude and Slackbot.

The authors set out a decision rule. Where users work on a Lightning Record Page or in a console app and do not ask an assistant for results, skip HXL and use standard page components, or a Lightning Web Component when those fall short. Where users ask for results in an assistant, let the assistant render the answer for exploratory questions, but ship a widget when the placement of fields, their grouping, labels and buttons matter. Their example is a sales manager approving discounts in Slackbot: a widget keeps the requested discount beside the policy limit with Approve and Reject buttons, whereas an assistant might reorder or omit the policy limit from one reply to the next.

On cost, the article argues that one widget replaces separate builds for each surface, such as a Lightning Web Component for Agentforce and a Block Kit message for Slack, so the investment pays off as the number of assistants grows. A widget is metadata-defined, composed in JSON from 22 HXL components such as rows, tables, badges, links, callouts and buttons, and is previewed with mock data in the HXL Playground. It connects to data through custom Lightning types that map an action’s output fields to widget attributes. For Agentforce you select the type as the action’s output rendering. For Slackbot, ChatGPT and Claude you attach the widget to a tool on a custom MCP server, which currently works only for invocable actions.

The limits matter as much as the method. The beta widget set has no chart component, so charts should be left to the assistant, or drawn with a Lightning Web Component when the user works in Lightning Experience. Interactive modelling, such as adjusting a discount and watching margin change, belongs on the record page rather than in a chat.

Read the original at Salesforce Architects (opens in a new tab)

Worth reading?

Must-read

Moving display logic from Apex into HXL widget formulas (opens in a new tab)

You will learn how to express conditional display, badge coloring, arithmetic and blank checks as formulas inside HXL widget JSON, what the formula functions can and cannot do, and why deployed widget schemas can only grow.

Before: Apex

  • Precomputes ratingVariant
  • Computes winRate in Apex
  • Sends hasPhone and hasOpenPipeline

After: widget formulas

  • CASE() picks the badge variant
  • IF() guards the win rate division
  • NOT(ISBLANK()) checks the phone
Display logic moves from the Apex DTO into the widget itself

HXL widgets are declarative JSON components, currently in beta, that can be embedded in Claude, ChatGPT and Agentforce. Their {!…} expressions can use math, comparison and logic operators and functions such as IF, CASE, AND and LEN, so display logic can sit beside the display rather than in Apex. The author shows an account card whose display fields were first precomputed in an Apex DTO and then replaced with formulas for visibility, badge variant, win rate and phone presence.

The author notes limits. There are no formatting functions for dates or currency, so those values still need formatting in Apex, and there is no aggregate such as SUM or AVERAGE across a list. Moving an existing widget also has a catch: a deployed schema.json can only grow, so removing old properties requires deploying a new widget bundle and repointing the Custom Lightning Type renderer.

The post also points to the Headless Experience Layer Playground for testing formulas live and to a formula reference in the Salesforce platform-widget-generate skill for coding agents.

Read the original at Salesforce Developers Blog (opens in a new tab)

Worth reading?

Must-read

Building interactive UI with the Headless Experience Layer for Agentforce and MCP clients (opens in a new tab)

You will learn how to structure declarative JSON widgets, bind them to Apex data using Custom Lightning Types, and configure Agentforce to render interactive cards instead of plain text.

  1. Write an Apex invocable method to return data
  2. Package the layout into a UiWidgetBundle
  3. Link output shape to widget via renderer config
  4. Update Agent Script to mark data displayable
  5. Test layouts in HXL Playground before deploy
Workflow for building and testing interactive widgets with HXL

The post introduces the Headless Experience Layer (HXL), part of Salesforce’s Headless Toolkit, which lets developers define an interactive widget once in declarative JSON and have it render natively in Agentforce and in any MCP client that supports MCP Apps. Instead of an agent replying with plain text, the same action can return a branded card that looks and behaves consistently across channels. Widgets are composed from reusable components rather than built as Lightning Web Components or React apps, and they only display what the underlying Apex action returns, so existing sharing and field-level security still apply. HXL rests on three concepts: components, which are surface-aware UI primitives; widgets, which combine components into a use case; and Custom Lightning Types (CLTs), which describe the shape of the data and whose renderer tells the platform which widget draws it and how fields map onto its attributes.

The authors illustrate the approach with a review card from Pronto, their fictional food-delivery sample app. The card is built from four pieces: a global Apex invocable action (GetCustomerReviewsAction) that returns review data; a widget whose files live in a UiWidgetBundle, namely a registration XML file, a JSON composition built from tile blocks with a forEach loop for list items, and an optional schema; a CLT that binds the action’s output to widget attributes using {!$attrs} and similar paths; and an agent output or MCP tool that marks the output as displayable. In Agentforce, the Agent Script sets is_displayable to True, and the model decides when to show the card, which in the authors’ testing usually happens on the first question of a fresh conversation. For MCP clients such as Claude and ChatGPT, two nested CLTs are needed because the tool output is wrapped in an envelope; only the outer type carries the renderer, and an MCP server entry publishes it as a UI resource that the tool references. The HXL Playground offers a browser-based way to preview layouts with sample data, though previews may differ from the live experience.

The post closes with getting started steps: enable Headless Experience Layer (Beta) under Feature Settings in Setup, use API version 67.0 or later, clone and install the Pronto app, and optionally use the open-source Salesforce Skills library to generate widgets, CLTs and MCP types with an AI agent. It also points to a hands-on workshop, and it presents HXL as a way to deliver consistent interactive UI across agent surfaces with less integration code.

Read the original at Salesforce Developers Blog (opens in a new tab)

Worth reading?