PCF SmartButton Control
Overview
The PCF SmartButton control provides dynamic, configurable buttons based on Dataverse settings. This control allows you to create flexible, context-aware buttons that can be used for custom actions and navigation in your Power Apps forms.
Features
The PCF SmartButton control includes the following features:
| Feature | Description |
|---|---|
| Dynamic Button Configuration | Configure buttons directly in Dataverse without code changes |
| Visibility Conditions | Show/hide buttons based on dynamic expressions |
| Custom Actions | Execute custom scripts or navigate to URLs |
| Field Value Integration | Use record field values in button labels, tooltips, URLs, visibility expression and action scripts. |
| Smart Caching | Optimized performance through intelligent caching of record data |
| Error Handling | Robust error handling and graceful fallbacks |
| Fluent UI Integration | Modern, consistent UI using Fluent UI components |
Installation
Prerequisites
- A Power Platform environment with Dataverse
- Solution Import permissions
Install steps
- Download the solution from the releases page.
- Choose the appropriate solution package:
- Managed Solution: For production environments (recommended)
- Unmanaged Solution: For development environments
- Import the Solution into your environment.
Configuration
Button Configuration Table
After installation, create records in the Button Configuration table with the following fields:
| Field | Type | Required | Description |
|---|---|---|---|
| Name | Text | Yes | Unique identifier for the button configuration |
| Table Name | Text | Yes | Entity/table the button appears on (e.g., 'contact') |
| Button Label | Text | Yes | The text to display on the button |
| Button Tooltip | Text | No | Hover text for the button |
| Button Position | Number | Yes | Numeric order for button placement |
| Button Icon | Text | No | Fluent UI icon name - Browse available icons |
| Visibility Expression | Text | No | Condition for showing/hiding button - The pcf context is available to be referenced. |
| URL | Text | No | The URL to navigate to when clicked |
| Show as | Choice | Yes | Choose between Button or Link display |
| Action Script | Text | No | Custom script to execute on click |

Dynamic Values and Tokens
All text fields (Label, Tooltip, URL, Visibility Expression, and Action Script) support dynamic tokens:
| Token Format | Description | Example |
|---|---|---|
{fieldname} |
Reference to a field value | {websiteurl} |
{lookup.fieldname} |
Access related record field | {parentcustomerid.name} |
{lookup1.lookup2.fieldname} |
Chain multiple lookups | {parentcustomerid.parentaccountid.websiteurl} |
Configuration Examples
Basic Navigation Button
To create a simple button that navigates to a website:
Name: View Website
Table Name: contact
Button Label: Visit Website
Button Tooltip: Go to {websiteurl}
Button Position: 1
Button Icon: Globe
Visibility Expression: {websiteurl}
URL: {websiteurl}
Show as: Button
Action Button with Custom Script
To create a button that executes JavaScript:
Name: Create Related Case
Table Name: account
Button Label: Create Case
Button Icon: Add
Button Position: 2
Visibility Expression: true
Action Script:
var entityFormOptions = { entityName: "incident", formId: "your-form-id" }; entityFormOptions["formParameters"] = { "customerid": "{accountid}" }; Xrm.Navigation.openForm(entityFormOptions);
Show as: Button
Advanced Usage
Filtering Buttons by Control
To display buttons only on specific control instances:
- Add the SmartButton control to your form.
- Open the control properties.
- Set a filter expression in the "Button Configuration Filter" property (e.g.,
contains(theia_name,'Control 2')).
This ensures that only buttons matching the filter will appear on that specific control instance.

Visibility Expressions
Use JavaScript expressions to determine when a button should be visible:
| Example | Description |
|---|---|
{revenue} > 10000 |
Show only for high-value accounts |
{statuscode} === 1 |
Show based on status value |
{parentcustomerid.parentaccountid.websiteurl} != null |
Show based on related record values |
{revenue} > 10000 && {statuscode} === 1 |
Combine multiple conditions |
Action Scripts
Examples of common action script scenarios:
var accountid = "{accountid}";
var name = "{name}";
// Open a record
Xrm.Navigation.openForm({entityName: "account", entityId: accountid});
// Show a notification
Xrm.App.addGlobalNotification({
type: 1, // INFO
message: "Processing "+name+"...",
level: 1
});
// Retrieve related record data
var id = "{parentcustomerid.id}";
const parentcustomer = await Xrm.WebApi.retrieveRecord("account", id);

Troubleshooting
Common Issues
| Issue | Solution |
|---|---|
| Buttons not appearing | Verify Table Name matches exactly with the entity logical name |
| Visibility expressions not working | Check that field names are correct and in proper case |
| Action scripts failing | Test scripts in browser console first to verify syntax |
| Related record values not loading | Verify lookup references use proper format and exist |
Note: Make sure you have the latest version of the control installed to benefit from the most recent bugfixes and improvements.

Like
Report
*This post is locked for comments