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.

Filter by
Sorted by
Tagged with
5
votes
2answers
296 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
435 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
220 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
525 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" ...
2
votes
1answer
727 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
279 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
3answers
10k 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 ...
2
votes
1answer
2k 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-...
3
votes
1answer
453 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 ...
17
votes
3answers
1k 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
922 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
2k 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
897 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 ...
-1
votes
1answer
3k 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
70 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 ...
1
vote
2answers
11k 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
409 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
2answers
2k 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
3k 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
468 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
789 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
969 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
4answers
974 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
76 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&...
1
vote
1answer
929 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
2k 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
2k 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="{}"...
3
votes
2answers
10k 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 ...
1
vote
1answer
993 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
1k 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
500 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({ ...
1
vote
2answers
528 views

How to bind 'this' to a function?

In backbone js I used to bind 'this' to function, something like this, this.someFunction = this.someFunction.bind(this); I would like to implement something similar in Salesforce helper function. Is ...
2
votes
1answer
665 views

How to pass a Javascript array to an Apex controller?

I have the following problem, I want to assign an array of javascript to a list of the apex controller. I have to update 3 list of the saleforce page with a "save" button and pass to the controller ...
1
vote
1answer
2k views

Exit from a Client Side function in Lightning?

Trying to do a if statement in a client side function. If the statement is true, you proceed with the action. If not, you exit from the function. Is this possible? doInit : function(component, event, ...
0
votes
1answer
2k views

Different ways to set value for a event parameter/ parameters

In the salesforce official doc- https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_event.htm I see two ways to set value for event parameters. 1)event.setParam("name", cmp....
0
votes
1answer
1k views

Passing parameter from javascript helper to apex method in lightning [duplicate]

This is related to Lightning component framework. Though, I have passed challenge (till 4), however result is not as expected. I am passing boatTypeId as a parameter from helper-onSearch to apex ...
1
vote
1answer
165 views

Lightning component - Custom Action on a Custom object- Add option to choose a case record type before creating a record

I have a custom button/action of Action Type: lightning component on a custom object that, when clicked, automatically creates a new case record of a certain Record Type, if it isn't linked to an ...
3
votes
1answer
3k views

Param passed from Lightning Component to Apex controller is read as null

I am trying to pass a string from my Lightning Component to an Apex controller, but when it is received by the Controller it is interpreted as null. The controller works fine and is returning data, ...
4
votes
2answers
2k views

Convert the any locale date format to US date format in Javascript lightning

I have been struggling to change the date format to US locale time. I tried so many methods but if fails at some or other scenario. The issue is I cannot say which Locale the client will be using. ...
0
votes
1answer
545 views

force:refreshView not refreshing fields

I am using force:refreshView to refresh the page but the fields that have been selected in the page layout are not getting refreshed. I change a checkbox from unticked to ticked and then refresh the ...
1
vote
1answer
3k views

How to call the setCallback function with a callback function

I am new to Lightning and am going through the Lightning Components Basics module. In the expensesHelper.js file would like to find out if it's possible to move the callback function definition ...
1
vote
2answers
1k views

How to focus an already opened but not focused tab in Service Console?

I would like to open a tab of a Contact in a Service Console: sforce.console.openPrimaryTab(null, CONTACT_ID, true); I can't make it though when it's already opened. I receive an error in browser's ...
0
votes
2answers
3k views

Create instance of wrapper class in lightning Controller

I want to use wrapper list in Lightning component want to add row dynamically in list but My controller fails at adding list element on init in a lightning controller Note: I want to add row ...
1
vote
1answer
3k views

How to refresh child component data from server based on data changed in parent component

I have two tabs, based on the inserted record in first tab, I'm displaying data in the second tab from server. if I go back to first tab and update the inserted record and then click on second tab it ...
5
votes
1answer
347 views

JavaScript function failing after spring'18 release [closed]

JavaScript function failing after spring'18 release. event.currentTarget.id event.target lightning component <aura:component implements="force:appHostable" access="global"> <div class="...
1
vote
1answer
286 views

How to solve race condition between afterScriptsLoaded and doInit in component

I'm working on implementing a map component with leaflet that needs to do two things. 1) Upon initialisation, get a list of the locations from the server 2) Once js libraries are loaded, use list of ...
2
votes
2answers
919 views

How to repeatedly poll a server-side controller for an action in a Lightning Component?

There's a Lightning Component with a button. Its onClick attribute points to a client-side controller's function. It invokes helper's function which I would like to start a polling routine to a server-...
1
vote
1answer
1k views

Unable to invoke action 'undefined': no controller and/or function found

Im trying to call a controller from my external js file, and im getting the title error, have you guys seen anything like this? Page: <apex:page controller="TestController" showHeader="false" ...
3
votes
1answer
568 views

Visualforce not defined

i was doing a page/script/controller functionality just see how it works, and for some reason i get the error "Visualforce is not defined". From what i got searching, this error shows when you dont ...
0
votes
1answer
1k views

How to define a field value of an object in javascript

I have an iteration over the values of a picklist in a lightning component. It dynamically generates checkboxes for every value of this picklist. I want to be able to use the value of this picklist ...