14 votes
Accepted

For SOQL queries, can "WITH USER_MODE" safely replace "WITH SECURITY_ENFORCED"?

We are recommending developers use WITH USER_MODE and avoid using the WITH SECURITY_ENFORCED In fact, at some time in the future, we may likely retire WITH SECURITY_ENFORCED The WITH USER_MODE ...
Mohith Shrivastava's user avatar
7 votes

Is it possible to import a dynamic custom label in LWC JS?

As of Summer '23, the Apex language now allows you to dynamically get a label WITHOUT using the visualforce trick above. There is a new method, system.label.get() which takes a label name (and ...
Christian Carter's user avatar
7 votes
Accepted

getRelatedListRecords sortBy direction

As per this documentation, You need to pass the - before the field name to get data in descending order. If the name is preceded by -, the sort order is descending. For example, Name sorts by name in ...
Tushar Jadav's user avatar
  • 1,477
6 votes
Accepted

Usage of tagName property on LWC - or existing browser Element properties

The LightningElement class extends a class called HTMLElementTheGoodPart, which in turn is imbued with HTMLElement.prototype properties through the BaseBridgeElement. As you may know, or might guess, ...
sfdcfox's user avatar
  • 487k
5 votes

Split HTML File in Single LWC Component

To use multiple templates, you create more components. This is the design philosophy of the Web Components design in general. If you're running into limits, you need to create additional components to ...
sfdcfox's user avatar
  • 487k
5 votes

Alternate to if:false in LWC

As far as I'm aware, you are meant to use either of the two solutions. I would personally recommend flipping the Boolean value, as that is a trivial code change. This is actually similar to most other ...
sfdcfox's user avatar
  • 487k
5 votes
Accepted

How do I mock a child LWC in a parent's Jest Unit Test?

In order to mock childComponent only in the test for parentComponent we need to: Build a skeleton stub for childComponent as a JS file. Instruct the parentComponent test to use this file instead of ...
Rob Baillie's user avatar
5 votes
Accepted

LWC: Getting original element that dispatched event that bubbles

This is the expected behavior, as specified in the documentation. When an event bubbles up the DOM, if it crosses the shadow boundary, the value of Event.target changes to match the scope of the ...
sfdcfox's user avatar
  • 487k
5 votes
Accepted

Why can't I set a wire apex class to a variable array in JavaScript?

Wire methods are asynchronous. That means you can't get the data during the construction of your component; myArray = this.opportunities; executes before getOpportunityList does. If you want to do ...
sfdcfox's user avatar
  • 487k
5 votes
Accepted

How salesforce component with different api versions interact with each other

Each unit is compiled according to its API version. However, when a transaction starts, the API version will be set according to whatever initialized the transaction. For example, a Visualforce page's ...
sfdcfox's user avatar
  • 487k
5 votes

How can the highlighting of a vertical tab when it's clicked be prevented?

This can be achieved by using pointer-events property in CSS: HTML: <lightning-vertical-navigation class="no-pointer-events"> CSS: .no-pointer-events{ pointer-events: none; } ...
Sneh's user avatar
  • 1,091
5 votes
Accepted

In uncompiled code, async await syntax is not supported by Lightning Web Security

tl;dr I've used async-await successfully for years now, with LS and LWS, it works just fine when used directly in a LWC component (compiled code). You shouldn't be getting this error unless you're (a) ...
sfdcfox's user avatar
  • 487k
5 votes
Accepted

Change the field label name in lightning-record-form component

lightning-record-form, lightning-record-edit-form, and lightning-record-view-form do not support custom field labels. The labels are rendered based on getObjectInfo call. For components that accept a ...
sfdcfox's user avatar
  • 487k
5 votes
Accepted

When will if:true stop working?

As of 2023-10-16, there is no ticking clock. Until salesforce.com officially announces deprecation, it is still technically safe to use if:true and if:false. After deprecation, we are guaranteed at ...
sfdcfox's user avatar
  • 487k
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, { ...
sfdcfox's user avatar
  • 487k
4 votes

TypeError: parameter 1 is not of type 'Event'

I hit this while extending LightningCheckboxGroup to make a new lwc "CheckboxGroupHorizontal". The only work around that worked for me was creating a new LWC called eventPasser: eventPasser....
Jamie Smith's user avatar
4 votes
Accepted

new lwc:ref does not work

So after some conversation with sf support we found out that the LWS needs to be enabled in order for this feature to work. Setup > Session Setting > Lightning Web Security > Use Lightning ...
Damecek's user avatar
  • 1,918
4 votes
Accepted

Reactive array of objects and "Use Lightning Web Security for Lightning Web Components"

Primitives are reactive, objects are not. However, you can just add @track to make an object reactive: import { LightningElement, track } from 'lwc'; export default class Widgets extends ...
sfdcfox's user avatar
  • 487k
4 votes
Accepted

LWC event.target.dataset sometimes empty, sometimes not

The inner div is the target, but the handler is in the outer div. Depending on where you click, a different target may be hit (parent vs child element). Use currentTarget, instead. The target is the ...
sfdcfox's user avatar
  • 487k
4 votes
Accepted

Flow is going back to first screen after clicking FINISH button on screen component

When you have a component that uses lightning:flow, it is your responsibility to ensure that you "close" the flow UI when the user presses Finish. This is covered in the documentation and I'...
Phil W's user avatar
  • 35.4k
4 votes

LWC: Tracking a shared imported variable

OK, I figured out a way with help from this StackOverflow answer. We can use a Proxy for the inputs object in the model, defining a custom setter for that proxy. The setter calls one or more listener ...
Matthew Souther's user avatar
4 votes

The updated @api value is not getting reflected in the child component in LWC

@api makes a property read-only. The parent component must not use @api for a property it intends to change. @api isfieldchecked = false; should be: isfieldchecked = false;
sfdcfox's user avatar
  • 487k
4 votes
Accepted

Refused to frame "vf.force.com/" because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self'"

Ok, the answer is right there on a Session Settings page in Setup. See Trusted Domains for Inline Frames Section: Visualforce Pages: Allow iframes of Visualforce pages with clickjack protection on ...
Vitalii Dehnerys's user avatar
4 votes
Accepted

Can you tell if an LWC is being used in a Flow?

Declaring a class property @api availableActions = [];, if the component is in a flow context, the framework will provide the following values: NEXT BACK PAUSE RESUME FINISH Then it could be used to ...
RubenDG's user avatar
  • 8,392
4 votes
Accepted

Show an error message in an LWC in a Flow using standard components

Other than using a customization such as unofficialsf.com's Show Toast Flow Action, I don't know of any standard way to address this issue. There are, however, many ways you could deal with errors, ...
Phil W's user avatar
  • 35.4k
4 votes
Accepted

LWC Errors in Winter 24

Salesforce posted a Known Issue yesterday that seems to cover this. I checked all my syntax and I found an extra </template> that wasn't causing problems before but was a problem now. Once I ...
Drew Tauber's user avatar
4 votes

How to develop Lightning LWC and Aura Components after Winter 24 Release without 10 minutes waiting and without cache clear and without Debug Mode?

It took me like forever but I found out that this as a new "feature": Changes to Aura components and Lightning web components (LWC) take up to 10 minutes to reflect in the UI Publish Date: ...
Uwe Heim's user avatar
  • 28.3k
4 votes

Make property unreactive

DOM updates don't immediately take effect, but instead are done the next time the browser takes control from JS. In other words, you're causing your own infinite loop. You should be able to fix this ...
sfdcfox's user avatar
  • 487k
4 votes
Accepted

refs vs querySelector in LWC

Should we mostly use refs instead of querySelector? Yes. Consider two analogies: (a) you walk into a store and walk up and down every aisle, considering every product, until you find the one you want,...
sfdcfox's user avatar
  • 487k
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.
Wes Lyons's user avatar
  • 301

Only top scored, non community-wiki answers of a minimum length are eligible