Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [javascript-controller]

A controller is a JavaScript Object, created by a standard JavaScript object constructor. In the Aura Framework, the JavaScript controller is client-side.

0
votes
0answers
24 views

Is it possible to set a value (in table) dynamically through lightning javascript event?

I have list of object records displayed in a table on lightning component. I would like to dynamically set a field value when another field value is changed. I should be showing the set value to the ...
0
votes
0answers
13 views

How to make Lightning:Inputfield as blank/null based on condition?

How to make Lightning:Inputfield as blank/null based on condition? I have tried different ways to accomplish this as below 1) component.find("auraID").set("v.value","") - I have used null/passing ...
0
votes
1answer
63 views

Simple Popover Example Causing: “Cannot read property 'na' of undefined”

I'm trying to get the popover example from the Salesforce documentation working and it's giving me an interupt error with "Cannot read property 'na' of undefined" message. All I have done is copy ...
0
votes
2answers
48 views

Parsing error: Unexpected token in below code of in Lightining controller

({ doInit : function(component, event, helper) { component.set(v.columns[ {label: 'Department ID', fieldName: 'DepartmentID', type: 'Auto Number'}, {label: '...
0
votes
0answers
22 views

Error message is not displayed on lightning table

I am using the below markup in the lightning table to show the error message. It is able to highlight the field in redborder but fails to show the error message. Is it not possible to update the ...
0
votes
1answer
20 views

How to send an arrayList from Apex to Javascript and then to HTML?

I'm new in JS and can't understand, what is wrong here (this is my test value, but then I want to send an arraylist's elements): Apex: public String test{get;set;} public String myApexMethod(){ ...
0
votes
2answers
33 views

How to retrieve the checkbox which were selected and deselected now -Lightning component?

I have a table where object records are displayed along with a checkbox. All the existing records are displayed with checkbox ticked. If the User deselects the checkbox on any of the rows I should be ...
1
vote
2answers
81 views

Does more logic on Client side reduces the lightning performance?

I am just struggling to understand on this as I develop a lightning component. I have object rows from apex controller which gets displayed on the component using <table>, <tr> and <td&...
1
vote
1answer
44 views

Unable to Call Apex-Controller Method in Modal-Footer Component

I have a modal with a footer. The footer is just for Cancel and Save buttons, and their respective JS functions. Modal Markup <lightning:overlayLibrary aura:id="overlayLib"/> <lightning:...
3
votes
1answer
48 views

Dynamic Button Icons in a Data Table Similar to Dynamic Actions in a Data Table

It's possible to have actions for each row in a data table that change depending on the contents of the rows (that are changed by those very actions). For example: The component reference provides ...
0
votes
1answer
20 views

Child component not displaying records from Parent record

I am passing the results from Parent component to Child component but the results are not displayed for some reason. I have gone through many example codes and it seems I have done everything ...
1
vote
1answer
45 views

Multiple calls to lightning:quickActionAPI getAvailableActionFields() fails

I get an error when doing multiple calls to getAvailableActionFields in a Promise.all(). The markup: <aura:component implements="force:hasRecordId"> <lightning:quickActionAPI aura:id="...
6
votes
1answer
70 views

Help Interpret Peculiar Way of Handling SUCCESS and ERROR in Lightning Callback

I didn't write but rather I'm reviewing the following Lightning JS function: InitializeComponent : function (component) { var recId = component.get("v.recordId"); var action = ...
1
vote
2answers
29 views

Help Interpret Advanced Array Work in Lightning JS

I didn't write but rather I'm reviewing the following Lightning JS function: InitializeComponent : function (component) { var recId = component.get("v.recordId"); var action = ...
5
votes
1answer
245 views

How to get the display density in a lightning components controller?

Is it possible to see if a user is in Comfy or Compact display density in a lightning controller? This is a new feature since Winter '19 and I cant find any documentation about this.
1
vote
1answer
36 views

Lightning Application Event Seems to Refuse to Fire

Event: <aura:event type="APPLICATION" description="Event is fired when boat type is changed in the BoatSearchForm component" > <aura:attribute name="boatTypeId" type="String"...
5
votes
2answers
32 views

Extracting a callback function

I have the following code in my controller: doInit: function(component, event, helper) { // Create the action var action = component.get("c.getExpenses"); // Add callback behavior for ...
0
votes
1answer
151 views

lightning:recordEditForm, mark as missing a field that I'm passing

I have an Issue with this component. When every Try to submit a new OpportunityLineItem The component sends the following error messages. An error occurred while trying to update the record. Please ...
0
votes
1answer
27 views

Enque action of javascript controller in lightning not working as expected

I want to call action1 server call after action server call gets over while doing enque. Since its not a best practice to call consecutively. I called the action1 inside action as shown below. Which ...
2
votes
0answers
31 views

controller throwing javascript error

I have a very basic controller function which is for some reason throwing a Javascript error. HTML where controller is called: <lightning:button label="Apply" iconName="utility:magicwand" ...
1
vote
1answer
28 views

displaying loading gif until server returns response?

i am developing a lightning component and i'd like to find out how to adding a loading image. Inside my controller i have a fetch() function which will get a server response. How can i display a ...
0
votes
1answer
29 views

Not able to print out fields of custom object

In my client side controller, I call a server side action that returns a List of custom objects. Each of those custom objects has multiple fields attached to it. When printing the values in the ...
2
votes
4answers
306 views

Accessing Map Value in Lightning Component

I've been trying to access map values in Lightning Components, but haven't been able to be successful. I've searched the documentation, articles, this forum, etc and the answer seems to be that there ...
0
votes
0answers
38 views

Unable to call Server-Side Action

I am trying to just execute a simple query and return a map <Id,List<object>> to client side helper. The method just isn't making the call to server side. Any help is greatly appreciated. ...
2
votes
1answer
271 views

Passing sObject List from Client Controller to Server Controller (Lightning Components)

Seems like I'm not being able to pass a sObject list to my server-side controller. I've seen articles and other forum answers that propose using JSON.stringify. I've tried that method, but my server-...
2
votes
1answer
55 views

DOM modifications from controller in lightning

While reading this article I met the following rule: Do not modify DOM in Controller. If you modify DOM in Controller it will call renderer method which will end in no result. The article looks ...
16
votes
3answers
927 views

What are the outer parentheses in Lightning controllers?

In every Lightning controller you have these outer parentheses wrapping the actual object: ({ getInput : function(cmp, evt) { var myName = cmp.find("name").get("v.value"); var ...
1
vote
2answers
576 views

Make a JavaScript class from a different file accessible in the lightning controller

How could I make a JavaScript class from a different file accessible in the arbitrary lightning controller? I found this question from SO, but it does not help me. So, the best way I was able to ...
3
votes
1answer
255 views

Array.filter() in Lightning Components

I'm trying to filter through an array of objects in a controller using the JavaScript filter() method. I get an error, however, that says, Uncaught Action failed: c:QuestionIteration$controller$...
0
votes
1answer
128 views

Using a custom lightning component within a form as an input field

Newbie to salesforce. We have built a multi-select lightning component that allows the users to select multiple values (based on auto complete). Example allows user to select multiple contacts from ...
0
votes
1answer
361 views

force:recordData not updating targetFields on reloadRecord

Working on the lightning component framework specialist superbadge, stage 6, and getting the following error: The BoatDetails component must use force:recordData to load the appropriate list of ...
1
vote
0answers
17 views

Wish to prevent agent closing tab in service console

I am trying to find a way to stop agents from closing their tabs in service console if they have unsaved changes in tab. I am using sforce.console.setTabUnsavedChanges to accomplish this. I know i ...
0
votes
2answers
558 views

How to iterate a list of sobject returned from Apex controller in Lightning JS controller

New to Lightning and trying to figure out how to process a list of sobject/custom metadata type records returned by Apex class in js controller before passing them to the component. Apex Controller ...
3
votes
0answers
129 views

Cannot read property 'appendChild' of undefined

I want to show the geoposition on a leaflet map lightning component. I enter an Id and get geolocation data accordingly. When I first enter an Id everything works fine, for the second time it shows ...
3
votes
1answer
204 views

unable to get index var from lightning:select option (undefined)

component.cmp <lightning:select name="Version" label="Select a version" disabled="true" onchange="{!c.itemsChange}"> <option value="">choose one...</option> ...
1
vote
1answer
380 views

Lightning component controller can't set pairs into attribute of type Map?

I have a lightning component that will display a long list of contacts (could be thousands), with a nested data table from a related object. That related data is editable, so I'll want to be able to ...
7
votes
1answer
87 views

Can we use the event's attribute “path” in Lightning?

I've been working on a pretty complicated component, and I've had all kinds of trouble simply trying to identify which element is currently being used. After all sorts of experiments, I found a really ...
1
vote
0answers
270 views

How to close a Salesforce lightning tab like below by use javascript?

I create a button link to lightning component,How to close a Salesforce lightning tab like below by use javascript ?
0
votes
1answer
146 views

Salesforce Calling Server Side action Infinitely from Lightning Component

I am facing a weird issue of Salesforce calling infinite times the Server side Action from the Lightning component. Has anyone faced a similar issue? I am pasting the code for your reference. <...
0
votes
0answers
204 views

Create a timer for items in aura:iteration

I have a list of cases that I'm displaying in an aura:iteration. The cases live in a queue that are displayed out to the users. I'd like to show a timer for each record that shows how long a given ...
0
votes
4answers
72 views

Lightning: setCallback() method is not been called, and no Error message is returned

Updated: Apex Code: public class MyAccountsController { @auraEnabled public Static List<Account> getAccounts(Id accountID){ List<Account> accountList = [Select Id,Name,...
0
votes
1answer
37 views

How to pass a parameter to Salesforce Lightning JavaScript controller method

I would like to pass a parameter to a JavaScript controller method so the method could format the data... Component <ul> <aura:iteration items="{!v.listOfStuff}" var="a"> <li&...
0
votes
0answers
369 views

Mouse over tooltip at cursor location

The goal is to display a tooltip of a comments content at the mouse cursor at the current location of an iterated comment field inside a Lightning component. Currently, on mouse over it fails with "[...
0
votes
1answer
270 views

Passing an aura:iterated list item to JS controller

The goal is to pass a "comment__c" rich text field on an iterated object to its JS controller to perform a string operation on it before it's returned to limit a tooltip it is to appear into 250 ...
1
vote
2answers
299 views

save two records in two objects with a single save button with lightning components

I have two objects: question and answer, in one form. the first 3 fields belong to the question object. dynamic form belongs to the response object. I created two actions in the client-side ...
1
vote
1answer
296 views

Cannot use push of undefined in Lightning

Why cannot I use the push method of the array in the case? Below you will be able to see that I am creating an empty array attribute named items in camping.cmp. I am setting it using the default="{}"...
1
vote
2answers
3k views

Get lightning:inputField value in javascript controller

I have following code in component which is called by another lightning component from aura:iteration. I want to get value from lightning inputField when it is changed in the javascript controller and ...
0
votes
1answer
134 views

How can I target lightning:icon and change its color?

What I want to accomplish is to show 5 stars in each row of a table. The users then can rate each row separately using the stars. However I just cant find out how to target the stars using the ...
1
vote
0answers
154 views

Star Rating in Custom Lightning component

I was doing the trailhead lightning-restaurant-locator And the trailhead is showing how to use Get request so by looping through the response, name and views are in a list. Now I want to add star for ...
2
votes
1answer
81 views

Why is enqueueAction not getting executed the second time?

I am currently writing a lightning component and came across this, ComponentController.js someFunction: function(component) { var action = component.get("c.apexFunction"); action.setParams({ ...