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
0
votes
1answer
65 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
646 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
1k 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
1k 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
7k 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
593 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
605 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
298 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
193 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
476 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
1k 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
1k 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
775 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 ...
0
votes
2answers
2k views

Lightning component quick action - redirect from Contact to User record detail page

I would like to know how to how redirect from Contact to related User record page via Lightning component quick action. Currently I have created Component which gets Contact record Id and passes it to ...
1
vote
1answer
123 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 ...
2
votes
1answer
2k 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
485 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
2k 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
2k 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
341 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
222 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
569 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
633 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
354 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 ...
1
vote
0answers
118 views

How to pas picklistvalues into label lightning component states Discription undefined

I want to pass the picklist values to a label of a checkbox but get error [Cannot read property '$getDescriptor$' of undefined] Here is my code apex controller: @AuraEnabled public List<...
1
vote
2answers
145 views

Pass a list collection from a search to new filtered list lightning controller

I have followed a tutorial to create a custom search lightning component to search a list of contacts based on an event search which works fine. What I would like to achieve is to get the result of ...
0
votes
2answers
5k views

Lightning button to redirect to record detail page

I am very new to lightning and have a basic issue with creating a button. My requirement is that when i click on 'check my budget' button it should redirect me to the corresponding budget record of ...
3
votes
2answers
17k views

Lightning response.getReturnValue() question

I did not find much info on the "response.getReturnValue" function and what it exactly returns. I understand that this is the function that must be used when a Client Side JS controller calls a Server ...
0
votes
2answers
5k views

Create New button on lightning Component

I have a lightning Component to display the Account and its Contact relationship in tree view using Accordion SLDS. On this page, I want to put "New Contact" button to create a contact record. Is it ...
2
votes
1answer
1k views

Multiple enqueueActions

Is it possible to have multiple enqueueActions? I know you can nest them as posted on this website https://developer.salesforce.com/forums/?id=906F0000000kKDRIA2. However, I would like to have ...
1
vote
2answers
4k views

Component Initilization Error: cannot read property 'g'

Everything was working fine with this component a couple days ago. Then I added an event and now I'm getting a strange error: Uncaught Component class instance initialization error [Cannot read ...
2
votes
0answers
293 views

Embed Lightning component in Leaflet map popup?

I'm using Leaflet inside a Lightning component to map locations of a number of entities. I'd like to display a Lightning component in the Leaflet popup for each entity, and I'm struggling to connect ...
1
vote
0answers
69 views

Lightning Attribute: Get JavaScriptObject

I have a lightning component with this attribute: <aura:attribute name="transportData" type="Object[]" access="global"/> I am getting the data from a http Request: $.ajax({ url: "...
2
votes
1answer
2k views

ComponentService.createComponents(): 'callback' must be a Function pointer. : false

I want to be able to call $A.createComponents(type, attribute, calllback); with values in an array. SF doc I am following: Dynamically Creating Components. But the obvious value of this would be to ...
1
vote
1answer
1k views

Understanding error: [Value number out of range for numberformat options property style]

I'm working through a Trailhead tutorial, and I am getting an error that confuses me. I've reduced it here to the minimum code I can for reproducing the error, and I'm hoping someone can explain to ...
0
votes
1answer
131 views

Error occurs as soon as I type in input

I am creating a lightning component that takes input and creates a new record with it. As soon as I type in the first input text field the following error occurs: TypeError: Error in $A.getCallback(...
0
votes
1answer
908 views

Using Callback when calling server side function

I load some values using <aura:handler name="init" value="{!this}" action="{!c.loadOptions}" /> in my component. I want these values to be populated when my component is loaded. Basically it is ...
3
votes
2answers
3k views

lightning:input help — keyCode

I'm seeking more info on lightning:input for use in a Lightning Component. What I want to do is have the input text field submit when the user presses the Enter key. However, the Enter key seems to ...
0
votes
1answer
2k views

how to do Lightning data binding between two components [duplicate]

How to show list of contacts in a child component based on the Parent component Account Id, I have a Parent component which shows the list of Accounts and I would like to get all the related contacts ...
5
votes
1answer
1k views

Can't get object property in lightning component controller

I am trying to access JS object properties in the client controller. I get undefined if I try access it by name. But I see the properties if I log the whole object. Something I am missing? var ...
3
votes
2answers
7k views

Scroll Page to top onClick of a button in Saleforce1

I have a problem scrolling to the top of a lightning component page in Salesforce1. I have tried using window.scrollTo(0,0); Added the below attribute in the button tag oncomplete="window....
0
votes
1answer
276 views

Conditionally display html based on apex:variable

I've seen Conditionally Render HTML in Visualforce but it seems to handle the checking on the apex side then simply reference that when determining whether to display but I don't think I can do that ...
2
votes
1answer
18k views

Lightning Component: Cannot read property 'get' of undefined

I've read through the different posts regarding this error, and for the life of me I cannot figure out why it's not working right.... I would really appreciate some help. I've checked to make sure ...
0
votes
1answer
120 views

Event Conflicts with DOM Style attributes

I have a parent component and one child component. Child component is a table which does calculation and the calculated value is sent to parent component through event. On each time calculate function ...
14
votes
2answers
3k views

Is it possible to clear force:inputField?

I have a force:inputField field on my lightning component acting as a lookup. It is working fine: <force:inputField aura:id="segmentid" value="{!v.campaign.Survey__c}"/> <ui:button press="{!...
0
votes
1answer
4k views

Lightning component javascript getReturnValue of String [duplicate]

Having Issues with getting the returned string from the apex controller. If I use getState and check if success it wont run and will only run if there is an error in the state. Just from a glance ...