Hot answers tagged

12

A "helper" class would be a utility component. For example, you can write the following code: import { ShowToastEvent } from 'lightning/platformShowToastEvent'; // This is the testUtil component function showToast(inpval) { const event = new ShowToastEvent({ title: 'Get Help', message: 'Input val changed.'+ inpval, }); this....


10

Badge is relatively very simple component. However, the main difference even for simple component is that lightning base components are loaded as custom components and you cannot reach into the DOM for customisation. For example, in lightning:badge, you cannot have hyperlink, but using raw HTML, you can have hyperlink as everything is in your hands. Sample: ...


8

Turns out the component had a css file that only contained '/**/'. I deleted the file and all is working again.


7

For reasons I don't understand, you have to invoke the setMessage method to output a custom message on the client-side: String m = 'My cusom msg here'; AuraHandledException e = new AuraHandledException(m); e.setMessage(m); throw e;


7

I had this issue myself today as well. In my case, I had a Quick Action Lightning Aura Component which enveloped a Lightning Web Component (because there is currently no way of using a Lightning Web Component as a Quick Action).. What I did is set up my Aura Component to catch 'close' events: <!-- aura/auraComponent/auraComponent.cmp --> <aura:...


6

@AuraEnabled methods are static for the same reason that Visualforce remoting methods are static: because those architectures don't maintain any state on the server. State would be represented as an object instance to which a member function is bound. In both paradigms - Aura and Visualforce remoting -, state is kept on the client in JavaScript. Since ...


6

Currently, there is no native solution for replacing custom labels tokens with dynamic values in LWC. But you can implement similar functionality using pure js. Let's create some service LWC component IntlService to be able to reuse its functionality from everywhere: class IntlService { static format(stringToFormat, ...formattingArguments) { if ...


6

You only need to declare @AuraEnabled once per type, if you use the comma operator to define multiple variables. In your case, you could write it as: @AuraEnabled public String var1, var3, var4; @AuraEnabled public Decimal var2; You do not need to add explicit default getter-setter { get; set; } in order for the variables to be accessible (this is a ...


5

Yes you should be able to do this by wrapping up the LWC base component in a custom LWC Component. You can use custom LWC component in an Aura Component. Use this link to understand how to use custom LWC in aura component: https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.interop_aura_composition This way you should be able to use ...


5

To remove lightning:datatable header you can apply attribute hideTableHeader For instance: <lightning:datatable keyField="id" hideTableHeader="true" />


5

This basically boils down to the main differences between Aura and LWC. Lets visit some of the practical differences: Aura is not truly component based framework. For example, when you define some styles on class my-class in 1 component, then those styles would apply to some other component in same window which uses the same class my-class. This would not ...


5

Using the component makes the code marginally more readable, and you get "free upgrades" if SLDS ever changes its specification of a badge. You're always free to use whichever you like. I would personally use the component as a matter of preference, since it is more consistent to read component code than raw HTML, especially in a larger component.


5

I am learning LWC, and I found out that I should not use as it's ECMASCRIPT 7 which means that it's using templates, shadow dom, web components and most of browsers are not ready for that. LWC polyfills everything not supported by the browser. There is no risk in using LWC, as all supported browsers will support LWC for now, and in the future. As browsers ...


4

You can you dataset attribute to get the current clicked div. <div data-id="thisDiv" aura:id="thisDiv">Click Me!</div> clickHandler : function(component, event, helper) { var id = event.currentTarget.dataset.id; //it will return thisDiv var getTargetedButton = component.find(id); //it will return the source button }


4

Looks like LWC references are case-sensitive and they should be referenced in the exact case like following <aura:component > <c:simpleTable/> </aura:component> While if we have Aura component called abc we can reference it in other components or apps as Abc or ABC without any errors, for LWC component this simply doesn't work.


4

In Aura you write with Aura syntax, so you reference the components the same way you have always done in Aura regardless of what type of component it is (Aura or LWC) <aura:component> <lightning:button/> <c:myFancyComponent/> </aura:component> Note that in the example above either component can be implemented in Aura or LWC and ...


4

The issue was where I was creating the event from import { LightningElement } from 'lwc'; export default class HelloWorld extends LightningElement { constructor(){ super() window.addEventListener("message", this.fireEvent, false, { once: true }); } } Should be... import { LightningElement } from 'lwc'; export ...


4

As another possible issue, you have a naming convention error. LWC automatically forces the LWC Class name to Pascal Case, but you have a dueling format right now: LWC class of HelloWorld <- this is Pascal Case LWC JS of helloworld.js <- This is not, it should be helloWorld, capital W. Template of helloworld.html (embedded in aura) I just tried this ...


4

window.setTimeout will run in a Global Context and thus this will point to that context. To be able to utilize this in Function Context (which is foo in this case), you will need to assign the local context prior to calling setTimeout and then utilize it as below: foo: function (component) { var myLocalThis = this; // capture the local context ...


4

A class can implement a static, Aura enabled, method, and still implement the Schedulable interface. But best practice is to create a controller with your @AuraEnabled method that calls a class that implements the Schedulable interface. global class MySchedulableController implements Schedulable { // runs a scheduled job at midnight Sept. 3rd. 2022 ...


4

You can use below method where you can pass objectName and comma separated picklist fields (even single field is fine) to get map of object and its picklist values of value and label: @AuraEnabled public static Map<String, Map<String,String>> getPicklistValues(String objectName, String picklistFields) { if(string.isNotBlank(picklistFields))...


4

Update: The underlying issue has been resolved. As a background information: This bug was recently introduced to the VSCode toolbox. Here's a bug report related to this: https://github.com/forcedotcom/salesforcedx-vscode/issues/1635 In order to deploy, right click on the LWC folder in the editor tree and select "SFDX: Deploy Source to Org". Using the ...


4

In lightning:badge, there is not much difference. Suppose there is scenario where you have a form and you want to build upload document functionality in form, then it will be to difficult if you are using native HTML tag and you need to write all logic manually so that it will work. But if you are using lightning:fileUpload tag, here you need to give some ...


4

There has no such limitation that you can't get the record id on User Record page through force:hasRecordId. I have tried a simple code and it works perfectly fine:- Component:- <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:...


4

In Aura, you cannot use spurious spaces wherever you like. This specific error is likely from code such as: data-value=" {!acc.Id} " > The extra spaces surrounding the string makes the system think you're trying to combine a string literal with a variable. This is not allowed. Make sure you do not use extra spaces in attribute values that ...


4

i have found 4 issues. your lightning component doesn't have Apex controller you have to add controller like below aura:component controller="myUtils" implements="flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes" access="global" > check spelling: thirdpartyClientCall and thirdpartyClientCaller check user profile Access for ...


3

I got this to work. Your SVG should look more like the following: <?xml version="1.0" encoding="UTF-8"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" display="none"> <symbol viewBox="0 0 100 100" id="requiredId"> <path fill="#f44" d="m54.3 74.1c-2.4 2.5-6.3 2.5-8.7 0-7.2-7.7-21-22.4-21-...


3

Users can technically modify any client code. You've taken a step in the right direction by using with sharing to prevent users from seeing records they don't have access to. The only flaw with your plan so far is that a malicious user could try to query fields they don't have access to. You would probably want to add some security by injecting 'WITH ...


3

Possible as of Spring 19. See here autocomplete—Controls autofilling of the field. This attribute is supported for email, search, tel, text, and url input types. The values on and off are supported, but the autofill behavior depends on the browser. When you set the autocomplete attribute, the lightning:input component passes the value through to be ...


3

It seems that $A.reportError does a little more than just report the error on the console. It gets the action of the exception, if available, and uses that as description. It will also wrap a non-Aura error, so that required information can be set to the error message. It seems that it will also post the error to the server: Post the action failure to ...


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