7

Please avoid spread operators unless you really want to concatenate two arrays purposely, spread operators are O(n), which has an non negligible effect on performance. The push() operation should be as observable as assigning a new array if the property is @track. https://developer.salesforce.com/docs/component-library/tools/playground/V4r9CeGW/2/edit


7

You do not need EMP-Connector if you are using lwc. Salesforce has a lightning-emp-api base component for it (https://developer.salesforce.com/docs/component-library/bundle/lightning:empApi). The lightning/empApi module uses a shared CometD connection. You can use the provided functions from the module import { subscribe, unsubscribe, onError, ...


6

event.target.values a string, not a date. You need to convert the value to date first then you need to subtract it. import { LightningElement, track } from 'lwc'; export default class LightningExampleInputDate extends LightningElement { @track date1; @track date2; @track result; datehandler1(event) { this.date1 = new Date(event....


6

Javascript is case SEnSiTivE. You have defined variable in apex as monthListBefore but in JS you are trying to access MonthListBefore, which does not exist. So, Try this.MonthList = data[0].monthListBefore;


6

Solution Add super() as the first statement in your constructor: constructor() { super(); // this is required console.log('constructing'); } Reason The requirement for a custom element constructor's first statement to be a call to construct the parent class (LightningElement) comes from the HTML: Custom elements spec and is referenced in the LWC ...


6

It's a known issue in the CLI and Salesforce is working towards the fix. The fix is scheduled to go out today (USA PST hours) Check th details here below https://github.com/forcedotcom/cli/issues/216 FYI - This issue is now fixed as per release notes https://developer.salesforce.com/media/salesforce-cli/releasenotes.html To get the fix run sfdx update


5

Looks like the string from apex is html markup, more likely from Rich Text Area. You can use lightning-formatted-rich-text to maintain formatting. <div> <lightning-formatted-rich-text value={stringFromApex}> </lightning-formatted-rich-text> <div>


5

Mix-ins are a fairly well-documented feature of many programming languages, including modern JavaScript/ES6. They are used to allow classes to inherit functionality from multiple other classes. MDN Web Docs Reference Wikipedia reference NavigationMixin is a class defined in the lightning namespace. It is documented here and here.


5

Community licenses don't support Streaming API, therefor empApi doesn't work. Streaming API is based on Push Topics and Read of Push Topics are not supported by Community License (so you can create events, but cannot subscribe to them)


5

You can refer to component reference library which has sample codes for all types of components, input types, Grid styles etc. Here is the LWC Component reference. There is tab next to component reference for developer guide. The Component reference allows you to view the same component code with Aura component by simply click on Switch to Aura Component ...


5

There's a great section called Sample Gallery on Trailhead where you can check different projects and use cases made with best practises in mind, provided by Salesforce.


5

Child-to-parent communication is always done with events. <c-modal open={openModal} onclose={notifyClose}></c-modal> ... // in modal this.dispatchEvent(new CustomEvent('close')); ... // in parent notifyClose() { this.openModal = false; }


5

You can't deploy it, because JSON.deserialize() method has different signature and takes a variable of String type as a first param, not List<String>.


5

You just need to prevent the template from rendering until the data is ready: <template if:true={names} for:each={names} for:item='name'> <div key={name.Id} class="customcss" > {name.Name} </div> </template> Further, the reason why it's called twice is because it will be called once with data from the cache (...


4

The detail parameter can contain complex data: this.dispatchEvent( new CustomEvent( 'update', { detail: { fieldName: this.fieldName, value: this.value } } ) ); Just be aware that you should avoid passing in actual objects inside the detail parameter, or your component's data may be compromised. See Create and ...


4

abc is an array, not a map. You cannot use get to get value in array of object. You have to use Array.find var staticKeyElement = this.abc.find(ele => ele.key === 'Static__c'); console.log(staticKeyElement.value); Sample Playground link : https://developer.salesforce.com/docs/component-library/tools/playground/K_PlRylL/1/edit


4

No. All components must be saved in a lwc folder. However, you can have multiple lwc folders in DX: /force-app/accounts/main/default/lwc/myAccountComponent1 ... /force-app/contacts/main/default/lwc/myContactComponent1 ... Each path is configured in sfdx-project.json: { "packageDirectories": [ { "path": "force-app/accounts", "default": true }, ...


4

The issue is happening because the parameter that is flowing from your lwc component to the apex controller is not in expected date format upon load. The parameter value that aura enabled methods with date format expect should be of type "yyyy-MM-DD" strictly. In your aura init method i did one line code change shown as below to match the format the aura ...


4

It seems that with Spring 20, the response from apex has become non-extensible with additional parameters. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions As workaround you can use result = Object.assign({}, result) for objects, or item = Object.assign({}, item) in a loop for each item in result for ...


4

There is a typo in code mentioned in the documentation example. The correct code is as below <apex:page> <apex:includeLightning /> <div id="lightning" /> <script> $Lightning.use("c:lwcvf", function () { $Lightning.createComponent("lightning:button", { label: "Press Me!" }, "lightning", ...


4

There doesn't appear to be anything wrong with your do-while syntax. However, it looks like there's a problem with your logic and what you're trying to accomplish that goes against best practices. You shouldn't place SOQL queries into iterative loops. It's inefficient and puts you at risk of exceeding Salesforce governor limits. Second, your loop is most ...


4

You need to tell the LWC compiler to use a relative path: import { isFunction } from './mycomponent-share';


4

Unfortunately, you cannot as noted in the LWC documentation. Setting up your development environment goes over how you can edit it, but also reiterates that you cannot develop in Developer Console.


4

you need to make this call from the connectedCallback() method. doing so will have resolved your import by this time. See below: import { myfunction } from 'c/reusableLWCFunctions'; export default class myLWC extends NavigationMixin(LightningElement){ connectedCallback(){ myfunction('THIS WAS CALLED FROM IMPORTED FUNCTION'); } } the ...


4

Not sure what you mean by "top level CSS" here. AFAIK you cannot modify the SLDS CSS that other components are using; you can only modify the SLDS CSS for your component. LWC automatically scopes the CSS you include in your component to apply to that component only via your component's name added as an attribute. See the answer on How to make buttons in a ...


4

Yes, this has been asked over and over here, and likely elsewhere as well. However, I'm not marking your question as a duplicate, as a matter of a slightly different nature in the wording deserves an answer. The "cacheable" attribute that allows the same method with the same parameters to not have to round-trip to the server repeatedly (thus improving ...


3

The issue is here. get eventOptions() { return this.eventsList.data.values; } this.eventsList.data is an array and does not have any values attribute.You can check the documentation, the array will be returned in data attribute You have to iterate over your eventList and create an array of options that can be used with Combobox. Something like: get ...


3

You can go by what Rahul has suggested, its called as Promise chaining. Modern javascript has new concepts that allow you to handle these complex requirements without making you go in promise chaining callback hell. Welcome Async and Await :) await - > The keyword await makes JavaScript wait until that promise settles and returns its result. ...


3

Short answer: you can't. The jsconfig.json file exists to help the IDE identify Javascript project directories to aid with code-completion mechanics. For example, a supported IDE might offer suggestions of other js modules when writing an import statement in another js module inside a directory with jsconfig.json in the root directory. In addition to this,...


3

Generic SObject and SObject[] are not yet supported at the interface between LWC and Flow (TLDR: You can't get there from here). We're working on it right now, though, and hope to get it into Summer '20. You can get an early taste for some of the experience by looking at how we implemented it for Apex Invocable Actions in Spring '20 We don't have any short-...


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