New answers tagged lightning-web-components
0
votes
Remove checkmark from LWC lightning-input toggle
You need to use the CSS to remove the checkmark from the toggle when the checked state. Use the border-style CSS attribute set to none. Add the below CSS code into your component CSS file.
.slds-...
0
votes
LWC CSP script-src self error
I ran into a similar issue (doing this from within a modal).
My fix was to use event.preventDefault();. So your method would look something like:
setSelectedStage (event) {
this.selectedStage = ...
1
vote
Share Content Version to Admin Users
Based on this docs, which was also mentioned on this question, it says:
Note: Depending on how files are shared, queries on ContentDocument
and ContentVersion without specifying an ID won't return ...
2
votes
LWC Invalid Mutation error when copying data from a @api property
part.IsReplace = false is a mutation of the object. You need to copy the object. Typically, when I add a field, I'll use the ... operator to copy the existing object and add new properties at the same ...
4
votes
Accepted
How to prevent LWC Wire from loading data automatically?
Don't call it via the wire service. Call the Apex method imperatively in your button's onclick handler.
5
votes
How to prevent LWC Wire from loading data automatically?
Wire methods with reactive properties don't call Apex until their reactive values are set to any value other than undefined. In other words, if you do this:
someProperty;
@wire(someMethod, { ...
0
votes
how to create lwc component to create new record for custom object ? only the name field is saving but other fields are not saving
In addition to Gaurav Suthar comment. Since Spring 20 release, the @track decorator is no longer required anymore to lwc attributes.
1
vote
Accepted
Place lightning-input message next to element
You can use custom CSS to make this work. use the float CSS attribute as follows:
<label class="slds-checkbox_toggle slds-grid">
<span class="slds-form-element__label ...
0
votes
lightning-input type="toggle" change label font
The best practice is to use styling hooks to customize the styles of the lightning-input component, rather than overriding the slds-form-element__label class.
Styling hooks are CSS custom properties ...
3
votes
Floating window in Salesforce account
You're looking for the Docked Composer. Unfortunately, it is not a standard component at the time of this answer. You'll want to vote on this idea. You can't really use the Docked Composer, but you ...
0
votes
Downloaded data in excel format using LWC in salesforce. When i open the file it shows warning prompt: File format and extension do not match
Use .xls instead of .xlsx, or use something like js-xlsx to create a proper XLSX file.
0
votes
How to determine when Queue is complete on LWC
Create a Message Channel, then in LWC, use the lightning-message-service to listen for that channel event, and finally, in your DeployCallback, you can use EventBus.publish to notify the LWC that the ...
2
votes
Accepted
How to clear LWC lightning-textarea in javascript
this.template.querySelector('lightning-textarea').value = '';
This should work, if you have one lightning-textarea. If you have several, it affects the first found.
But querySelector fell out of ...
0
votes
How to prevent LastPass from displaying icon inside lightning-input
This CSS snippet helped me where autocomplete and data-lpignore did not work, out of box:
div[data-lastpass-icon-root] {
display: none !important;
}
0
votes
Dynamic lightning-button-menu causing infinite loop
I was missing the most obvious choice here add an onclick to the menu that creates the list used to create the entries, this will ensure that the most updated data is used when creating the menu ...
0
votes
Navigate to LWR Community Home Page
The possible reason for this error is that the navigation service requires a context to perform the navigation action, and the context is lost when the modal is closed.
To fix this, you may need to ...
1
vote
Use of criteria filter on the subscribe platform events
This Add a Filter with the Tooling API page goes through the steps. There's no UX to do this.
Add a PlatformEventChannel
/services/data/v59.0/tooling/sobjects/PlatformEventChannel
{
"...
0
votes
How to access the specific element from List<String> in HTML <template> file directly in LWC?
Like what @stackasaur said, your best option is to use a getter. You can simplify the getter with:
get fourthItem(){
return this.stringList?.at(3);
}
If you really need a way to retrieve items ...
0
votes
Redirect to 'create new record' page from flow
so if I well understood, the record is created, and you want to redirect user to created A1 record?
If yes, you should use such link: /lightning/r/objectName/recordId/view
The link you added will ...
2
votes
Accepted
can showToast be utilized in LWR site (Experience Cloud)?
Note that from the Summer '23 release, you can use https://help.salesforce.com/s/articleView?id=release-notes.rn_lwc_toastcontainer.htm&language=en_US&release=246&type=5
1
vote
How can I refresh a child component from its grandparent?
From what I can tell, in order to refresh the display of the child component, the cache of the parent (and not necessarily the one of the grandparent) needs to be refreshed.
You seem to have guessed ...
0
votes
Accepted
Lightning layout issue when containing accordion
The Salesforce Lightning Design System (SLDS) CSS won't work correctly unless you follow the rules. In this case, a lightning-accordion-section should be placed directly inside the lightning-accordion....
1
vote
How to use Lookup Field in LWC
Since this is the first result I get when I search on the web, I want to point out that salesforce just implemented a solution for this:
https://developer.salesforce.com/docs/component-library/bundle/...
0
votes
Account deletion job based on object relations
This code has a lot of problems, such as not caring about governor limits, not actually checking for the related objects, and so on. Here would be my attempt to fix most of the problems. One thing I'...
0
votes
Wrap LWC in Aura so it can be opened on click of a button in a pop-up window
Aura is visually very similar to LWC. You have a top-level component, and you'll have your LWC component in the markup.
<aura:component implements="force:hasRecordId,flexipage:...
2
votes
I need to get Lightning page name using lwc
I use CurrentPageReference:
import { CurrentPageReference } from 'lightning/navigation';
...
pageName;
@wire(CurrentPageReference)
wiredCurrentPageReference(currentPageReference) {
...
0
votes
Download file in lwc
The answers listed above did not work for me. I would highly recommend downloading the "FileSaver" JS library (https://github.com/eligrey/FileSaver.js).
After you download them, you'll add ...
1
vote
Accepted
Quick Action for LightningWebComponent not Possible for Task SObject
See the documentation.
You can create object-specific actions on many objects, including:
Account
Campaign
Case
Contact
ContentNote
Custom objects
Group
Lead
Opportunity
1
vote
Dynamic component creation in Lightning Web Components
As of Winter '24, it is now possible to dynamically create LWC components within another LWC. Full details available here: https://developer.salesforce.com/docs/platform/lwc/guide/js-dynamic-...
0
votes
Accepted
LWC navigate to the record detail page after creation
You are not handling the result of your createRecord correctly. In your then, you need a parameter for the record. Then you can get the Id from that. Currently, you're using event.detail.id but there ...
0
votes
Can I get the aura component code for resizable div
This code is trivial to convert to Aura. Here's how to do it.
Template
There's three changes we need to make the template work. First, we need to convert each click handler from ={method} to ="{!...
0
votes
Email validation not working in LWC lightning-input
If you define the regex in the LWC JS file, you'll have to use double backslashes as mentioned by sfdcfox. I had a similar issue while back, and the solution was to escape the hyphens which did not ...
0
votes
I am trying to fetch Account details with the text provided in lightning input lwc
this is because, when the input change, meaning when user type in something, you are handling the change, but you are not calling the handleSearch() method at all when the input change.
To achieve ...
0
votes
I am trying to fetch Account details with the text provided in lightning input lwc
Without a button to trigger the search, you need to make the searchTerm reactive:
So instead of
getRealtedSearch({ searchTerm: this.searchTerm })
you would use :
getRealtedSearch({ searchTerm: '$...
1
vote
Accepted
RefreshView API in Quick Action
I took @Felix's idea and made a slight modification: instead of subscribing to CDC, I created a custom message channel and published a message from the quick action when applicable. The refresh ...
1
vote
Why Salesforce doesn't provide router for Lightning Component(LWC, Aura)?
Salesforce doesn't provide a built-in router for Lightning Components (both Aura and Lightning Web Components) similar to what is available in some other web frameworks.
However, you can implement ...
0
votes
Accepted
Is allowing "data:" in CSP Trusted Sites a security concern?
The Data URI scheme has been known to be exploitable, but the risk level depends on the environment. If there is a way for a malicious actor to trick the system into delivering a malicious payload, ...
3
votes
Accepted
Override the style (color)of Lightning-button-icon on bare variant in LWC
If you want to change the background
CSS
.icon-b {
--slds-c-button-color-background: yellow;
}
If you want to change the icon itself:
CSS
.icon-b {
--slds-c-icon-color-foreground: yellow;
}
...
0
votes
Using 3rd Party JS library in LWR Community
You can implement your own version of platformResourceloader
import jquery from '@salesforce/resourceUrl/jquery';
...
connectedCallback(){
...
this.loadScript(jquery);
//instead of loadScript(this, ...
0
votes
lightning__commerce_cartChanged channel is not updating the amount of cart items in the LWR site
One hint, while it is not clearly described in Salesforce documentation. Commerce/cartApi method addItemsToCart parameter has a such structure:
{"productId_1": quantity_1,"productId_2&...
0
votes
LWC Quick action on WOLI (Work Order Line Item) not showing up in Dynamic record page
Took me a bit to figure this out, but you have to enable this functionality via a permission set first. It only works for Field Service orgs on the Field Service Mobile app.
To get LWC Quick Actions ...
0
votes
@wired method not detecting reactive parameter change when calling refreshApex
When you first assign the property value, then call refreshApex immediately, the wire handler hasn't had a chance to be notified of the change yet, as this happens later in the LWR life cycle, so it ...
2
votes
Accepted
Trouble loading PDF.js lib in LWC
When you do loadScript you need to point it to the .js file in your static resource, not just the folder name.
For example, instead of loadScript(this, pdfjs), you need to do loadScript(this, pdfjs + &...
1
vote
An internal server error has occurred on Experience cloud site with embedded Google Map
The issue you faced was a multi-customer issue. The GACK -1685232593 points to java.lang.NullPointerException and the Salesforce Product team has filed a bug #W-14417472 internally to fix the issue.
...
2
votes
Accepted
How to remove the row from a lightning data table
That code is just wiping out the table data entirely. Instead, you will want to use Array.prototype.splice with exactly two parameters, the index to start at, and the number of elements to delete (1). ...
0
votes
Accepted
An internal server error has occurred on Experience cloud site with embedded Google Map
I am currently experiencing the same bug, I dont know when it started and I dont know how to fix it.
The only thing I know is that it works in the partial and dev orgs. Only in the production ...
0
votes
How to modify the height of a lightning-combobox dropdown?
you can try = slds-dropdown_length-10
0
votes
How to set default picklist value for lightning-combobox?
To set the default value of the lightning-combobox as the first picklist value, you need to modify your JS code slightly. You need to assign the value property of the combobox to the value property of ...
1
vote
Issue embedding link in custom label in LWC
To display the HTML link you need to use lightning-formatted-rich-text component as below.
<lightning-formatted-rich-text class="myClass" value={errorText}></lightning-formatted-...
1
vote
Accepted
Lightning-Input type=date unable to replicate error
Update: This is resolved. The issue replicated one day and in Chrome Dev Tools you could see that the Label values were null. We imported them per Salesforce documentation, but found it's a known ...
Top 50 recent answers are included
Related Tags
lightning-web-components × 8425javascript × 1307
apex × 1093
lightning × 881
lightning-aura-components × 539
lightning-datatable × 428
lwc-wire-adapter × 420
html × 335
css × 326
community × 246
salesforcedx × 242
lightning-experience × 230
lwc-dom × 200
aura × 184
lightning-design-system × 179
visualforce × 171
slds × 167
lwc-jest × 163
visual-workflow × 144
js × 119
lightning-recordeditform × 107
wire × 102
lightning-combobox × 100
datatable × 97
navigationmixin.navigate × 93