We’re rewarding the question askers & reputations are being recalculated! Read more.

Hot answers tagged

57

First off: "Lightning" is a larger (marketing) effort to rebrand existing and new Salesforce1 platform services under one shiny new umbrella. "Salesforce1 Lightning" consists of the following pieces, among others: Lightning Schema Builder (rebrand of Schema Builder) Lightning Process Builder (rebrand of Visual Workflow) Lightning Components (new - port of ...


54

The problem is that the constructor for the AuraHandledException only sets the string argument to be the message sent to the client-end, while calling getMessage() on the exception through apex returns a different string that the constructor defaults to the value "Script-thrown Exception". Obviously, this leaves something to be desired for testing purposes, ...


46

Answering my own question. The Lightning Components Developer's Guide has the following: The Aura object is the top-level object in the JavaScript framework code. For all the methods available in the Aura class, see the JavaScript API at https:/[mySalesforceInstance].lightning.force.com/auradocs/reference.app, where [mySalesforceInstance] is the name ...


27

Salesforce1 is indeed built on Aura, as confirmed in Josh Kaplan's (Salesforce Aura Product Manager), Dreamforce 2013 session, Introducing Aura: Rapid Mobile Development with Reusable Components. It is also using the Salesforce Mobile SDK as well. This great collection of Dreamforce 2013 sessions featuring Salesforce1 also references the Aura session. ...


23

While the above answer from Andrew Fawcett is spot on, I am thankful to Jesse Altman who did a brilliant detailed blog post on this subject in response to my question. I am sharing it here for everyone's benefit. Quoting the relevant excerpts from Jesse Altman's blog post. So, how are Salesforce1 and Aura related? Well, Salesforce1 is built on ...


19

That is a bug, although there is a simple workaround. In your component markup put the SVG in a DIV, wrapped with a CDATA block: <div aura:id="svg_content"> <![CDATA[ <svg width="120px" height="120px" viewBox="0 0 120 120" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g stroke="...


17

I'm afraid you can't. I would like to be able to do it to, at least customize the behavior of the "Save" button, but unfortunately it's not possible. As you said, you need either to put the button inside your component with force:lightningQuickAction, or recreate everything in a component with force:lightningQuickActionWithoutHeader. Solution 1 is easier ...


16

Having played a little with lightning web component during pilot, I think yes sooner or later everyone will be using lightning web components to build their apps. To begin with currently what i know is it lacks support for communities or flows and many other areas (Official docs are yet to be released so we will come more when docs go out on 17th Dec). ...


15

It does not look like a variable defined as indexVar was meant to be used as part of another expression. e.g. this works <aura:iteration items="{!v.contacts}" var="item" indexVar="index"> {!index} : {!item.FirstName}<br/> </aura:iteration> I think in your example "item" should be changed from final value to an object which has ...


15

You could implement infinite scrolling similar to what I did for my custom Lightning Component that renders data table. In your main component's render.js file attach a listener to the window.onscroll event. As the user scrolls down the page the below code detects once the user has neared the bottom then can take action. In my example, I invoke helper....


15

Pagination isn't accomplished server-side in Lightning; but instead done by client-side code. See my gist for an example that loads up to 50,000 rows. If you need more than that, you simply need to load the data from the server in pieces, as demonstrated here; basically, just query X number of records, and if there's still more data to get, use the ID as a ...


15

The documentation covers this explicitly: To compute a value for a property, use a JavaScript getter. For example, to convert the name to all uppercase letters, use a getter function in the JavaScript class, not an expression in the template. Getters are much more powerful than expressions because they’re JavaScript functions. Getters also enable ...


13

The framework will never have a way for you to get the parent component. That breaks encapsulation. You have two options: Fire an event that your containing component can listen for and act upon. Pass in a reference to the attribute to the child component. <c:childComponent myValue="{!v.B}"/> When the childComponent updates myValue, v.B will also ...


13

You are hitting a timing issue with init that is by design - you should not use component.getElement() in init because elements are not reliably available in init handlers - you'll want to look into using a custom renderer afterRender method which gets called at a point where you are guaranteed to have actual DOM elements available and was designed for ...


12

You can get the keyCode from the event object .Below is what I tried and worked ({ searchEvents: function(component, event, helper) { console.log(event.getParams().keyCode); if(event.getParams().keyCode == 13){ alert('Enter key pressed'); } } }) You can also use which as well .Below is the console.log of whole event object


12

Yes, $A is how you gain access to the underlying Aura framework, such as enqueuing actions, getting application events, managing the Aura rendering life cycle, and various utility methods. You can view the available methods using AuraDocs, located on your server at /auradocs/reference.app. You can access it using the production or sandbox links I've provided ...


11

You need to use sobjectType as the attribute of default object. Not sObjectType and not SObjectType. i.e. <aura:attribute name="acc" type="Account" default="{'sobjectType':'Account', 'Name':'Account123'}"/> Starting from Spring 15 Lightning Compomnents markup is case sensitive (Release Notes) therefore you get an error when referencing ...


11

Methods in Lightning components do not return a value, also came to the same outcome as yourself. However, I did learn to use and love component events with dynamic event handlers. What you can do from the calling component is fire a component event from within the component you wish to call the method on currently and attach a dynamic event handler for ...


11

Unfortunately I wasn't able to make it work using the class directly, either with an inner class or even a top level class. Using the second solution with a String attribute in your AuraEnabled method and then deserialize it is the best solution I've found. It works for both inner class and top level class. I've just published a blog post to list all the ...


11

The reason only one item could be returned as the result of a find() call is that we keep a map of ID to component in our services. "myId": "1:0" If you register two components with the same ID, we convert it to an array. "myId": ["1:0", "42:0"] If you then destroy one of those components, it stays an array. "myId": ["1:0"] I do think there might be a ...


10

To add to Zach's detailed answer, note that the UI Plugins are part of an upcoming set of product features currently referred to as Lightning Extensions. These are in pilot for Winter '15, and will likely remain so for at least one more release. If you're interested in joining the pilot, please contact your SE, TSE, etc. and ask that they nominate you. Stay ...


10

This example loads items on the client-side and captures the selected text value in the DOM. See the next example to capture the selected text value on the object itself. <aura:component> <aura:attribute name="list" type="String[]" default="Item 1, Item 2, Item 3"/> <aura:attribute name="selected" type="String[]"/> <ul> ...


10

Lightning aura:iteration over two objects with dynamic key In this example I am using contact object and we will get contact' Account info as well as owner info.. For now I am hard-coded API name but you can use Field set as well.. Apex class public class GetAFewContacts { @AuraEnabled public static list<Contact> getContacts(){ ...


10

You can access the attribute as v.navItemPrivs.Task and that should work just fine. Object properties are accessible by dot notation but not brackets unless they are integers. Unfortunately you can't bind to dynamically named keys (e.g. you can't do v.myMap[v.myKey] in Lightning so far). Be aware that under the current way Locker functions (as of Summer '16 ...


10

I have now solved this issue in my app. The root cause was that I am using dynamically created components and I wasn't explicitly declaring them as dependencies in their parent component. So I had code like this: $A.createComponent( "c:officeHoursTable", { "contactList": component.get("v.contactOfficeHours") }, function(newList) { ...


10

Very interesting question. I did some research on it and found this gitHub repository, someone has tried to play with default values of all kinds of basic types. Scene 1: Simply putting the below line doesn't work. <aura:attribute type="Datetime" name="datetimeDefaultWithTimeString" default="2013-03-06T10:17:36.789Z"/> however if you do the exact ...


10

There are four different things that work different and should not be mixed up: Attributes visible to Apex (System.debug(object)) Attributes visible to JSON.serialize Attributes visible to Aura Attributes visible to VisualForce At the end of this post, you will find the class with different types of attributes (public; getter; getMethod; auraEnabled; ...


10

Currently no. The issue is that the body attribute for buttonMenu is of type Aura.ComponentDefRef[] vs the usual Aura.Component[] Because of that, items passed to v.body are expected to be templates to create components vs actual components. So you can't dynamically create the menuItem instances. If you explain more why you want to do that, I could ...


10

My take on this. I have only been playing around with LWC since it was officially announced yesterday. I am not sure if a broader audience would have a detailed hands-on in LWC unless they were part of Pilot. With LWC announced only yesterday, it still has a long way to go before it can be widely adapted. Going through the documentation this morning, ...


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: ...


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