Questions tagged [lightning-web-components]

This tag is for questions related to JavaScript, CSS, or Markup when used in the Lightning Web Component (LWC) programming model, or for questions of interoperability between LWC and the original Aura-based lightning components.

1,577 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
8
votes
3answers
6k views

Get records in Lightning web components without APEX

import { LightningElement, track, api, wire } from 'lwc'; import { getRecord } from 'lightning/uiRecordApi'; const FIELDS_SOLICITUD = [ 'DCABM_obj_solicitudABM__c.DCABM_fld_aplicacionSolicitud__c'...
7
votes
2answers
230 views

Event propagation with bubble true in LWC

I'm trying learn event propagation in lwc. As per the documentation says {bubble: true, composed: false} means the event does not cross the shadow boundary. but it bubble up the shadow boundary I don'...
7
votes
1answer
8k views

querySelector not getting element in lightning web component

I am creating a popover, where I need to position it correctly based on the button's position that triggered it. It starts like this: <div id="popoverWrapper" class="popover-wrapper" style={...
6
votes
0answers
322 views

How to get a PageReference from Site.login(username, password, url) in an Apex Test

When I run this code from within a LWC controller: ApexPages.PageReference pageRef = Site.login(username, password, url); It returns a valid PageReference instance. But when I test the code in a ...
6
votes
0answers
579 views

External Objects not supported in Force.com sites

(Edit: all of this is happening only in a Force.com site. The Lightning Web Component is not the source of the problem) I'm trying to query an External Object inside @AuraEnabled method, but I'm ...
5
votes
1answer
78 views

LWC multiple apex calls on initialization (Best practices question)

PROBLEM: I have a LWC component which needs to gather data from different objects on initialization event (Objects are: custom object, files and metadata type). This is what I have in place working ...
5
votes
0answers
62 views

Can I get all existing Pages for a Community using Apex?

I would like to create a custom component to use in Experience Builder, and this component will allow a configurable navigation to another page. I would like to use a dynamic picklist with Apex to get ...
5
votes
1answer
85 views

Why are SObject fields returned to an LWC via @AuraEnabled Apex immutable?

I get this error: TypeError: 'set' on proxy: trap returned falsish for property 'cvcp__ReturnToWorkType__c' when attempting to set a value via JavaScript inside an LWC (Lightning Web Component): sob....
5
votes
0answers
150 views

Neither forceCommunity:routeChange or aura:locationChange cannot detect the URL change with history.replaceState

We have a use case where a lightning component built in LWC, should trigger a URL change. We're handling that with the history.replaceState method(note that we encountered the same problem with ...
5
votes
0answers
589 views

How to dynamically import a module in lwc

I am trying to import modules dynamically in my LWC component. While pushing the change I get a strange error LWC1509: This experimental syntax requires enabling the parser plugin: 'dynamicImport' ...
5
votes
1answer
486 views

Multi language support in community built using LWC (Migration from Visualforce to LWC)

We have an Identity community which supports more than 50 languages built using visualforce pages. We would like to migrate the community to LWC. For that, main issue we are facing is the language ...
5
votes
0answers
255 views

Architecture decision: use canvas app or lightning out?

Suppose we need to develop an app which can be used both inside Salesforce and in another web site. And definitely we don't want to duplicate the code. So basically there are two options here: ...
5
votes
1answer
2k views

I can't load PDF.js lib in Lightning Web Component

I'm creating an lwc component that shows a pdf with canvas, the lib I'm using is this:PDF,js when trying to load lib, returns me an undefined error, can someone help me how to load correctly My Html ...
5
votes
1answer
442 views

UI API within LWC as an ISV. What should be the approach when wire adapters are not feasible?

I have a lightning web component that needs to call UI API. I can't use the LWC wired adapters because the 'getRecordUi' does not take the "childRelationships" parameters like the 'record-ui' endpoint ...
5
votes
0answers
753 views

My LWC test is not displaying code coverage

I have configured jest for Lightning web component test. My tests are running and passing but code coverage not displaying into output. Following is package.json file: - { "name": "my-...
5
votes
1answer
2k views

event.getSource() alternative in LWC? (considering origin reparenting)

Consider below component chain in Aura: <c:parent> <c:child> <c:grandChild> When grandChild fires event, we can get hold of the source component by using event....
5
votes
0answers
688 views

lightning-record-edit-form component not being record-type aware

I wrote a lightning web component that includes a lightning-record-edit-form component. We are using PersonAccounts here and there are 2 RecordTypes on PersonAccount as well. The Type__c field is a ...
5
votes
1answer
236 views

Lightning Web Component Slots in App Builder

Need some help, not even sure if this is possible... In Lightning App Builder, the standard tabs component has "Slots" where tab content can be placed. My question, is this available for LWC through ...
5
votes
0answers
977 views

Does ui:scrollerWrapper have an equivalent in Lightning Web Components?

Using slds-scrollable class in Lightning Web Component works in desktop browser but not on Salesforce Mobile app. For Aura components you would use the ui:scrollerWrapper to accomplish this. I've ...
5
votes
0answers
705 views

Lightning Web Components: Set scroll position on lightning-datatable based on 'key' field value

We are looking to auto-scroll the user to a specific point in a lightning-datatablewhen a button is clicked. Assuming we referenced the key-field attribute data-row-key-value in the dom then in HTML ...
5
votes
2answers
3k views

Property value is not refreshing on Template when its Non-Primitive type

I am trying to update value of property in Parent Component which is pass in Child component. But after update value is reflecting in child component'c class (.js) but not in view (.html) Is it ...
4
votes
0answers
46 views

How to make a required `lightning-input-field` field not required?

Is it possible to make a <lightning-input-field> where field-name is required (such as Contact.LastName) not required on the UI? I would like the field to not kick in validation rules (client ...
4
votes
0answers
32 views

How to handle Platform Event while UI is being rerendered?

Use case: We have Digital Experience (i.e Community) where at first we perform the action and after it, we redirect to a new page. This action also publishes Platform Event (Notification) which should ...
4
votes
0answers
101 views

Lightning record page printable view or PDF

I need to create a printable view (or PDF) of a record's Lightning Page (think "tear sheet") that includes a compact "details" section, compact related list tables, and a custom ...
4
votes
0answers
38 views

Are fully custom SLDS themes possible in communities?

Bootstrap has a "themes" mechanism where a HTML page using the Bootstrap class names can be presented using many different colour schemes, fonts, spacing etc. For example: or and it is ...
4
votes
1answer
660 views

You can’t remove the following public properties because the component is part of a managed package

I am trying to push a JS file in a LWC Component and am unable to do so with this error lwc/boatMap/boatMap.js-meta.xml: You can’t remove the following public properties: boatId, because the component ...
4
votes
0answers
42 views

When will ::part be available and will header cells in lightning-datatable be allowed for overriding?

I am specifically asking about the answer provided here We have many projects which have community implementations. As it is well known that communities tend to have their own themes and styles, the ...
4
votes
0answers
209 views

Lightning Map(Lwc) is not working on playground and documentation demo

Lightning map demo from the LWC documentations is not working. I am getting the below error. Unable to resolve forcehelp/linkToNonSalesforceResource from api/runtime/lwc-components/1.5.6-alpha/...
4
votes
0answers
644 views

Google Analytics Event Tracking in Community using LWC

I'd like to use Google Analytics Event Tracking inside a Community in LWC We have Google Analytics configured in Builder > Settings > Advanced > Google Analytics The documentation says to ...
4
votes
0answers
617 views

Detecting change on Record in Lightning Web Component withing Communities

I am looking for a solution to a basic scenario: A User in a Community submits an Opportunity, this Opportunity is enriched with data synchronously upon insert and asynchronously through ...
4
votes
0answers
227 views

Why can't I skip LWC namespaces in namesspaced scratch org

I have an LWC component as part of a managed package. To support Classic its also embedded inside VF page using a Lightning App(Aura): <apex:page standardcontroller="Account"> <apex:...
4
votes
3answers
564 views

Proper namespace syntax for importing static resource into LWC?

I have a static resource named 'myResource' that contains a javascript file 'myfile.js' I can correctly import like this: import myResource from '@salesforce/resourceUrl/myResource'; Then when I ...
4
votes
0answers
390 views

LWC @wire order of execution not working for ie11

I have implemented a lightning web component (lwc) that shows a dependent picklist field To load a dependent picklist in lwc I use @wire with getPicklistValues and because getPicklistValues requires ...
4
votes
2answers
842 views

How to @wire an external Rest API call with LWC OSS?

I have created a basic project and simply want to pull a list of greetings from Google Firestore instead of using the default static array of greetings. My greeting.js file looks like this: import { ...
4
votes
0answers
742 views

lwc getFieldValue from a custom external object

I am creating a LWC that handles data from an external object. I have access to the recordId through @api recordId;, but I need to get the externalId from this object as well. Currently, I have call ...
4
votes
0answers
4k views

NoErrorObjectAvailable Script error. Salesforce LWC

[NoErrorObjectAvailable] Script error. We trying to update the record data dynamically. we are sending the data from child to parent. We are trying to update the JSON object based on dynamically key ...
4
votes
0answers
295 views

Warning when setting input value in test

I'm writing unit tests for LWC using lwc-jest but when I try to follow the pattern documented in the Basic Lightning Component section of this documentation https://developer.salesforce.com/docs/...
4
votes
1answer
601 views

Lightning Radio/Checkbox option level helptext

Just wondering if it is possible in LWC to provide help text at a option level for radio-group or checkbox-group? We are wanting to provide further details about why a user might select each option. ...
4
votes
0answers
306 views

Jest Unit test an event that dispatches inside XMLHTTPRequest (XHR)

How do I test an event that does an XHR request and dispatches an event? I managed to install the dependencies to mock the xhr using https://github.com/jameslnewell/xhr-mock/tree/master/packages/xhr-...
4
votes
0answers
646 views

Using Javascript window.confirm() in Lightning Experience

We are using window.confirm() in the JS parts of Lightning Aura Components and embedded Visualforce pages (iframed). This worked just fine for several years. Yesterday I noticed that in both use ...
4
votes
0answers
598 views

Getting Organization Id in a Lightning Web Component?

I found you can get the current user id like this: import id from '@salesforce/user/Id'; I have a really simple component where all I need are the User Id and the current Org Id. I haven't been able ...
4
votes
0answers
1k views

Unable to resolve custom label in lightning web component

With reference to the document Access Labels for lwc, I created few custom labels and used them in my web component; most of the labels were unable to resolve. I don't understand why exactly. To ...
4
votes
0answers
2k views

Error while loading a js as static resource in lightning Web component

I have a static resource name KendoUI, which is a javascript and is public. In my application, I have this : import { LightningElement } from 'lwc'; import { loadScript, loadStyle } from 'lightning/...
4
votes
0answers
530 views

LWC: Add a region in custom community theme

I would like to add a region in my custom community theme. For now I am only able to add my LWC components in the body area and would like to know how I can declare regions in my theme to accept LWC (...
4
votes
1answer
834 views

Dynamically accessing iteration item properties in a Template iteration on lightning web component?

I would enjoy using the easy to set up lightning-datatable, but it just lacks any ability to really customize it. It would work, but I need text-wrapping in cells instead of truncation. And it lets ...
4
votes
1answer
1k views

LWC Datatable - Turn Custom Lookup Field Value in Editable Datatable to Draft Value for Mass Update

As you know, datatables do not support lookup field. I've built a search lookup field that queries an object, and added that to the LWC datatable as a custom type. The id of the selected record (...
3
votes
0answers
32 views

How to force cache refresh on community when releasing to production?

We have a community composed of multiple LWC. We are planning to release a big update in our production environment. When testing in other environments, some testers who had used the community ...
3
votes
0answers
27 views

Prevent private custom LWC from being visible in Lightning App Builder

this is a bit of a newbie managed package question. We've built a custom LWC that is composed of a number of child components, and everything is going to be added into a managed package. What we ...
3
votes
0answers
68 views

Call Screen Flow from LWC in Partner Community

I have some LWC buttons on a Partner Community and I want to call Screen Flow. My plan was to wrap the LWC in an Aura Component, send a customEvent from LWC, get the customEvent in the Aura Component ...
3
votes
0answers
51 views

Declaratively mocking a custom LWC in a single unit test

The approaches suggested of using jestconfig module mapper or the mocks folder work well if you have a single mock per component you are testing, but not if you have to build how your parent component ...

1
2 3 4 5
32