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.

78 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
0answers
261 views

Passing a variable to lightning component through snapin chat

I have a snapin chat component embedded on our custom application (not salesforce or a community). I'm trying to allow a parameter to pass through to my lightning component for use in the prechat ...
5
votes
2answers
10k views

How do you set a default value on lightning component force:inputField which is a lookup?

I have a lightning component (Summer 16) which contains a "Task" attribute as follows: <aura:attribute name="task" type="Task" default="{ 'sobjectType': 'Task' }"/> Further down the page, ...
3
votes
0answers
428 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 ...
2
votes
0answers
533 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
0answers
376 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 ...
2
votes
0answers
388 views

JS controller - get all aura:attribute

I've got component with some attributes. For example: <aura:attribute name="missedCalls" type="List" access="global" /> <aura:attribute name="tryingToInitiateCall" type="Boolean" access="...
2
votes
0answers
420 views

ui:inputCheckbox disabled property not working in Microsoft edge

I am dynamically rendering disabled property of checkbox to true or false from controller. This works fine for other browsers but does not for Microsoft Edge. The checkbox remains disabled, i.e it is ...
2
votes
0answers
402 views

How to use Jasmine unit tests and still get past Lightning CLI?

Like the question says, I'm trying to work out some best practices and frameworks stuff with my team. One of the things we want to do is unit test our lightning components. I really like Bob Buzzard'...
2
votes
0answers
906 views

Lightning component - Javascript function to fetch picklist values for multiple fields

I built a lightning component where multiple fields with type picklist needs to be shown in the UI. I added a javascript function to fetch the picklist values and also built a generic method where it ...
2
votes
0answers
704 views

$A.createComponent throwing error when trying to create the same component for second time

I have to add and remove components from a Modal dialog - so using add code: $A.createComponent("pbrdev:TransactionViewer", { thistrans: ...
1
vote
1answer
186 views

getParam("outputVariables") return undefined

Im using an aura component as an action button to display a flow on lightning experience. At the end of the flow I need to redirect the user to the new record created in the flow. COMPONENT <aura:...
1
vote
1answer
2k views

Default a dynamic value in Combobox onload LWC

I am retrieving a set of values from apex through JS, I want to preselect the the first option in the Lightning-combobox (the retrieved values are different for different users). I used @track ...
1
vote
0answers
312 views

How to update an LWC when a trigger updates a record

I have an existing LWC, we have a community page that holds it and one other LWC (which is part of a managed package we cannot control or edit). The managed component sends and receives data for ...
1
vote
0answers
422 views

Map - get key value in aura component

I'm trying to get the key/value pair in the aura component Aura component: <aura:attribute name="countryMap" type="Map" default="{}"/> <aura:attribute name="currentCountry" type="String" /...
1
vote
1answer
986 views

Change field value in lightning component

I'm trying to change the value of the field Instagram_followers__c of my Influencer__c object in my lighthning component. It's a really simple component: a refresh button wich check the number of ...
1
vote
0answers
979 views

Add addEventListener for blur to lightning:inputField

I want to invoke a method when inputfield is off from focus state(blur). I am trying as below but i am not able to get the alert statement when the cursor is out of focus from field . Can some one ...
1
vote
0answers
511 views

Get event source from onclick handler in outer div

In my lightning components, I am trying to create a system that keeps track of every button that gets clicked inside my component. Having an event that fires whenever any button is clicked turns out ...
1
vote
0answers
75 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
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 ?
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
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 ...
1
vote
2answers
534 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 ...
1
vote
0answers
188 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
0answers
81 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: "...
1
vote
0answers
576 views

Salesforce Lightning Component refreshes the entire page

I have a lightning component to add and remove the rows. Whenever I click the delete button, instead of deleting the selected row it refreshes the entire page. This is working fine when I tested on ...
1
vote
0answers
176 views

Hide selected value from picklist

I want to hide the selected value from picklist so that in next picklist that value shouldn't appear. I have a grid in which I have 5 picklist so If I have selected 1st value in picklist that value ...
1
vote
1answer
289 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 ...
0
votes
0answers
8 views

Populating date on e.force:createRecord

I'm trying to populate the last day of the year on the CloseDate (Date) field. I've tried everything from this link: https://stackoverflow.com/questions/13255114/retrieve-the-last-day-of-the-year-in-...
0
votes
1answer
18 views

Close child Visualforce page from parent visualforce page

We have a child visualforce page that opens from parent VF page using standard controller. We enter some values that needs to be updated back to parent page and close the child VF page. We want to ...
0
votes
0answers
42 views

Trying to insert 2 records in 2 custom objects which AREN'T in a Relationship via Lightning Aura Component

I am trying to create a record in 2 objects at a time. Object 1 = Guest_Master__c Guest ; its fields =Guest_First_Name__c, Guest_last_name__c, Guest_email__c, Guest_phone__c. Object 2 = ...
0
votes
1answer
24 views

Drag Drop records in canvas giving error Aura lightning

I am trying to display all records in a card format and trying to drag and drop it in a canvas. When i am trying to drag an element its giving the below error <aura:component controller="...
0
votes
1answer
25 views

Information about event in JS controller in AURA

I would like to know where I can get relevant information about the methods that have the event of the aura controller, i.e. this my_function: function(cmp,event,hlp)... I know a lot of the others, ...
0
votes
1answer
38 views

Update record on server using lightning component

may I know why this code does not change/update the field object data? By default, the field object (Final_Approved__c) is false. The type is a checkbox. This code is in lightning environment js. ...
0
votes
0answers
17 views

Import Metadata Records from Salesforce Schema

What I'm trying to do is to get the metadata record FieldApiName from the salesforce Schema in the next way import MetadataRecord from '@salesforce/schema/CustomMetadata__mdt.metadataRecord__c'; But ...
0
votes
0answers
25 views

Object's field value into an aura component

I am not very familiar with aura component. How I get the value of a field into an aura component (more exactly, inside the controller .js of a component)? (Es: status of case) Thanks in advance :)
0
votes
1answer
38 views

Aura Component / Controller.js debugging : custom follow / unfollow button for Knowledge Article

I have created an aura component to allow client to follow /subscribe to an article. When a user clicks on the button subscribe, a record is created in Salesforce /Record created in Salesforce/ ...
0
votes
0answers
44 views

Get DOM elements to hide an element from afterRender event in Lightning component

I am trying to access Page related DOM elements which are not part of aura component. I am trying to access elements with the help of afterRender. I am able to get the element but i can see only proxy ...
0
votes
0answers
36 views

How can i assign/Change value to a variable of one JS file into another JS File (LWC)

In LWC, is there any way to change the value of a variable that is located in another JS file & some other JS file changes that variable value which have impact on the first file variable? Regards ...
0
votes
0answers
54 views

Rich text Area Issue- Apostrophe converting to some html tags

How to remove the html tags and get the original content in lightning because in classic it appears correctly but when i switch to Lighting it is adding &" something whenever i am writting &...
0
votes
0answers
22 views

Cannot access DOM element from extension

I currently have an extension that has similar functionality to Google's autocomplete. This extension is intended to work in the Service Console in the Email tab (where an agent replies to tickets) ...
0
votes
0answers
137 views

Create Account record with image using Lightning component

I have made a component which will create the Account records, i want to upload image as well along with the rest of the fields while creating the Account record. i tried Lightning:fileUpload, but it ...
0
votes
1answer
79 views

Can anybody suggest me how to implement jquery sparklines in LWC

I have Loaded jquery sparklines static resource downloaded from https://omnipotent.net/jquery.sparkline/#s-news still i cant use functions in it to implement sparklines in LWC this is my html code <...
0
votes
0answers
23 views

afterRender CSS isn't initialised

I have this afterRender function: ({ afterRender : function(cmp, event) { this.superAfterRender(); console.log(cmp.find("map_div-ID").getElement().style); var h = ...
0
votes
0answers
139 views

Lightning out App error in callback function When I try to display Lightning component inside a VF Page

Hi I have created a VF page to call a Lightning component. The function of the lightning component is to display value on it based upon the record ID in Lightning page. Now in Classic UI we are trying ...
0
votes
0answers
17 views

Is there any to check scheme url available or not in Salesforce App

Currently I face a problem, my product like follow structure. I want to know if our customer install My App or not, if not I will show a dialog tell him to install My App. I want to ask about is here ...
0
votes
1answer
267 views

Update multiple record edit form records on single button click

I have a requirement where we need to submit multiple record edit form data on single custom button click. Below is my approach for the requirement. I need to save the record edit form data on click ...
0
votes
1answer
620 views

We added the header Access-Control-Allow-Credentials to true

We load JS code by creating a script tag with dynamic src endpoint and append the script element into the page our src will call resource apex class (@RestResource) I know that Community domain is ...
0
votes
1answer
80 views

How to avoid having multiple values when assigning a variable multiple times

I need to avoid getting duplicate values when I assign a value like this: hoursWorkedHelper : function(timeSheets){ const hoursWorkedByContact = new Map(); if(timeSheets){ ...
0
votes
0answers
820 views

Callback failed Error for Lightning Aura Component

I am facing the below error for the Lightning component. I tried to debug but was not able to find the root cause. This page has an error. You might just need to refresh it. Error in $A.getCallback() ...
0
votes
0answers
247 views

Parameter to apex method is going as null when setting parameter in Lightning JS

I have an add row and save button on a table. When i click on add row, the row gets added and as soon i fill the data and then click on save button, it returns null. After looking into debug i ...