

Quick Actions in LWC – Global vs Object-Specific
In Salesforce development, Quick Actions have always been a reliable way to speed up common processes. Whether creating a record, logging a call or triggering a custom component, they will give users a way to perform tasks without leaving their current context. With Lightning Web Components (LWC) maturing into the default development model, the question naturally comes up that how can Quick Actions be integrated with LWC? And more importantly, what’s the difference between Global Quick Actions and Object-Specific Quick Actions when used in LWC?
Understanding the nuances between these two types of actions helps us design the right kind of user experience and select the correct technical approach. While the end goal for both might be similar to offer an easy, guided way for users to do something the scope, placement and context in which they operate can be quite different.
Understanding Quick Actions in Salesforce
Quick Actions are buttons in Salesforce that allow us to perform specific tasks directly from record pages, the global actions menu, or even in mobile contexts. They can be configured declaratively in Setup and then linked to either standard behaviors (like creating a record) or custom components.
Salesforce offers two types into that:
- Global Quick Actions: Available across Salesforce, regardless of the object page the user is on.
- Object Specific Quick Actions: Taking care of a particular object’s record page and being able to access that record’s context automatically.
Object-Specific Quick Actions with LWC
Object-specific actions are tied to a particular object. When placed on that object’s record page, they automatically pass along the record context, the recordId to the component. This makes them perfect for scenarios where the new record should relate to the current one or where the context of the record should influence the behavior of the component.
For example, imagine a need to create a Contact from an Account page without navigating away. An object-specific Quick Action would be ideal, because it can directly associate the new Contact with the Account being viewed.
Below is an example implementation where an LWC is used as an object-specific Quick Action to create a Contact:

Post clicking on action from account record page:

HTML
<template>
<lightning-card title="Quick Create Contact">
<div class="slds-p-around_small">
<lightning-input label="Last Name" value={lastName} onchange={handleLastName}></lightning-input>
<lightning-input label="Email" type="email" value={email} onchange={handleEmail}></lightning-input>
</div>
<div class="slds-p-around_small slds-text-align_right">
<lightning-button label="Cancel" onclick={handleCancel} variant="neutral"></lightning-button>
<lightning-button label="Save" onclick={handleSave} variant="brand"></lightning-button>
</div>
</lightning-card>
</template>
JavaScript
import {LightningElement,api} from 'lwc';
import {createRecord} from 'lightning/uiRecordApi';
import {ShowToastEvent} from 'lightning/platformShowToastEvent';
import {CloseActionScreenEvent} from 'lightning/actions';
export default class CreateContactQuickAction extends LightningElement {
@api recordId;
lastName = '';
email = '';
handleLastName(e){ this.lastName =e.target.value; }
handleEmail(e) {this.email=e.target.value; }
handleCancel() { this.dispatchEvent(new CloseActionScreenEvent()); }
handleSave() {
if (!this.lastName) {
this.showToast('Error','Last Name required','error');
return;
}
const fields = {LastName: this.lastName, Email: this.email, AccountId: this.recordId};
createRecord({ apiName: 'Contact', fields })
.then(() => {
this.showToast('Success', 'Contact created', 'success');
this.dispatchEvent(new CloseActionScreenEvent());
})
.catch(err => this.showToast('Error',err.body?.message || err.message,'error'));
}
showToast(title, message, variant) {
this.dispatchEvent(new ShowToastEvent({ title, message, variant }));
}
}
Meta XML
< ?xml version="1.0" encoding="UTF-8"? >
<LightningComponentBundle xmlns= "http://soap.sforce.com/2006/04/metadata" >
<apiVersion>64.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__RecordAction</target>
</targets>
<targetConfigs>
<targetConfig targets="lightning__RecordAction">
<actionType>ScreenAction</actionType>
</targetConfig>
</targetConfigs>
</LightningComponentBundle>
This setup automatically injects the Account Id (recordId) into the component when the action is invoked from an Account record page. That way, the new Contact is directly related to that Account.

After hitting save button from this action contact will be created in our org:

Global Quick Actions with LWC
Global Quick Actions differ in that they are not tied to a specific object.They appear in the global actions menu(the “+” icon in Lightning Experience) or can be added to page layouts across different objects and on the home page. Because it’s not linked to a specific record, they do not get a recordId automatically.
There is an important technical note: when creating certain objects like Tasks using the lightning/uiRecordApi modules,errors might occur because not all objects are supported in the UI API. In such cases, Apex becomes the better option for record creation.
A working example is a global Quick Action to create a Task. Since Task is not a UI API supported for record creation, an Apex method handles the insert.
Once implemented below solution UI will look as below:
Once filled details for task it will create and show us with the id:



HTML
<template>
<lightning-card title="Quick Task">
<div class="slds-p-around_small">
<lightning-input label="subject" value={subject} onchange={handleSubject}></lightning-input>
</div>
<div class="slds-p-around_small slds-text-align_right">
<lightning-button label="Cancel" onclick={handleCancel} variant="neutral"></lightning-button>
<lightning-button label="Save" onclick={handleSave} variant="brand" ></lightning-button>
</div>
</lightning-card>
</template>
JavaScript
import {LightningElement} from 'lwc';
import createTask from'@salesforce/apex/QuickActionTaskService.createTask';
import {ShowToastEvent} from 'lightning/platformShowToastEvent';
export default class QuickTaskLwc extends LightningElement {
subject = '';
description = '';
handleSubject(e) { this.subject = e.target.value; }
handleDescription(e) { this.description = e.target.value; }
handleCancel() {
this.dispatchEvent(new CustomEvent('close'));
}
async handleSave() {
if (!this.subject) {
this.showToast('Error','Subject required','error');
return;
}
try {
const id=await createTask({subject:this.subject,description: this.description});
this.showToast('Saved',`Task created (Id: ${id})`,'Success');
this.dispatchEvent(new CustomEvent('saved'));}
catch (err) {
const msg = (err?.body?.message) || (err?.message) || 'Unknown error';
this.showToast('Error', msg, 'error');
}
}
showToast(title, message, variant) {
this.dispatchEvent(new ShowToastEvent({ title, message, variant }));
}
}
Meta XML
<?xml version="1.0"encoding="UTF-8"? >
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>64.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
<target>lightning__HomePage</target>
</targets>
</LightningComponentBundle>
Due to Quick Action in Lightning must be an Aura component or a supported LWC target, we used an Aura wrapper here to host the LWC in a global Quick Action.
Aura Wrapper
<aura:component implements="force:lightningQuickAction" access="global">
<c:quickTaskLwc onsaved="{!c.handleSaved}" onclose="{!c.handleClose}" />
</aura:component>
Aura Controller
({
handleSaved : function(component, event, helper) {
$A.get("e.force:closeQuickAction").fire();
},
handleClose : function(component, event, helper) {
$A.get("e.force:closeQuickAction").fire();
}
})
Apex
public with sharing class QuickActionTaskService {
@AuraEnabled
public static Id createTask (String subject, String description ) {
if(String.isBlank (subject) ) {
throw new AuraHandledException('Subject is required');
}
Task t = new Task(Subject = subject, Description = description);
insert t;
return t.Id;
}
}
This approach allows the Task to be created regardless of the context from which the global action is launched.
We can click on this ‘+’ icon for global actions from any page:


To add our LWC in global action: Setup->Global Action-> New

Then will need to add it to publisher layout:

Key Differences Between Global and Object-Specific Quick Actions
When working with LWC and Quick Actions, the choice between global and object-specific approaches changes both the development pattern and the user experience:
- Context: Object-specific actions receive recordId automatically, while global actions do not.
- Placement: Object-specific actions live on record pages for a specific object. Global actions appear in the global menu and can be added to many places.
- Data Handling: Some objects (like Task) cannot be created via UI API, which means Apex is needed regardless of whether the action is global or object-specific.
- Component Wrapping: Global Quick Actions often require an Aura wrapper when the LWC doesn’t directly support the lightning__RecordAction target.
The above differences will help us to determine the right tool. If our component should always be aware of the current record, an object specific action can make sense here. If it needs to be available everywhere in the org, a global action is better suited.
Conclusion
Quick Actions in Lightning Web Components offer flexibility and speed, enabling faster workflows right where they are needed. Object-specific Quick Actions excel in contextual scenarios, carrying record information seamlessly into the component, making them perfect for related record creation and updates.Global Quick Actions will be able to offer accessibility across the Salesforce experience anywhere, though often will require additional acceptations like Apex for unsupported objects or an Aura wrapper for LWC compatibility.
By understanding these all differences and by the use of the right approach for each case, we can create experiences that can feel natural to end users and require fewer clicks to achieve the goals. Whether it is a Contact creation flow directly to an Account or a Task creation form available from the global menu, the use of Quick Actions and LWC delivers both performance and usability, lying the gap between Salesforce’s declarative configuration and the custom requirements of modern business processes.






