Questions tagged [javascript]

Javascript is a weakly typed interpreted programming language primarily implemented by web browsers to allow for client-side scripting. It can be used in Visualforce pages to give a more dynamic experience to end users. Additionally, the Visualforce engine generates and uses JavaScript to support the functionality of some of its components.

Filter by
Sorted by
Tagged with
149
votes
3answers
24k views

End of javascript sidebar workarounds? (Salesforce Classic / Aloha)

Reading through this doc: Docs.releasenotes.salesforce We replaced the rich text editor in HTML Area home page components with a new version that supports more markup but doesn’t allow HTML to ...
48
votes
1answer
15k views

How do I start to debug my own Visualforce/JavaScript?

This question is intended to complement How do I start to debug my own Apex code? as sometimes questions are asked here that could most easily sorted out by the questioner using their browser's "...
47
votes
2answers
29k views

What are the available $A JavaScript functions in Lightning?

The Lightning Components Cheat Sheet lists a few common $A functions and the Lightning Components Developer Guide references some others that are useful for certain situations. I can view the $A ...
44
votes
2answers
9k views

Changing the color of a custom button

Is there a way of changing a custom button color? Not a button on the visualforce page but rather the ones created under custom and links on an object. Thanks. -K
36
votes
6answers
4k views

Why do we still need to hack the Sidebar? Usecases - Workarounds - Alternatives

Since it seems to me, that a lot of people still need sidebar workarounds, I would be interested to learn about the use-cases, experienced challenges and (most important) possible strategies to avoid ...
33
votes
4answers
6k views

Namespace Prefix in JavaScript and Apex within Installed Package

When you have a dedicated Visualforce Page and can use modern JavaScript Remoting techniques, this is seldom an issue. But I'm looking at some historical code in a managed package like this: {!...
29
votes
5answers
13k views

Lightning: Bug in Lightning framework when using aura:renderIf?

I have a Nav component which contains the following: <aura:renderIf isTrue="{!v.showAllProducts}"> <c:showAllProductsCmp/> <aura:set attribute="else"> <c:...
27
votes
2answers
4k views

Requirescript change in Winter '16 release

As per release winter 16 release notes: http://releasenotes.docs.salesforce.com/en-us/winter16/release-notes/salesforce_release_notes.htm In summer 15 release salesforce disabled JavaScript hacks ...
27
votes
2answers
1k views

Parallel Execution of JavaScript remoting calls

I was hoping to be able to fire off multiple JavaScript Visualforce remoting calls in parallel and have the execute simultaneously, and for me to deal with the responses asynchronously. Whilst in ...
26
votes
2answers
14k views

Custom labels in javascript

How one can access custom labels in javascript linked as separate static resource? For example, some user action on the page should trigger confirmation dialog with custom message. And this message ...
26
votes
1answer
3k views

Lightning experience page rendering is slow

I've developed a lightning component(actually about 4 sub-lightning components all included on a main component) that queries for records, displays them to a user, and has a form for contact ...
25
votes
2answers
899 views

Javascript Remoting breaks on complex relationship data

We use Javascript Remoting to retrieve some complex data from the controller. The SOQL query looks like the following: SELECT Id, ( SELECT Id, Sales_Rep__r.Name, Customer__r.Name, ...
24
votes
6answers
26k views

How can I execute JavaScript on a SFDC Standard Detail Page?

*NOTE: This is not feasible as of the latest SFDC Releases. * I have a requirement to execute some JavaScript on a SFDC Standard Detail page. Specifically we would like to remove the ability for ...
24
votes
2answers
2k views

Do promises work in Lightning?

I wrote some code that uses promises. It seems that in the Promise environment, I can queue an action, and the action callback is never called. In the callback environment, when I queue an action, ...
23
votes
3answers
5k views

Javascript Remoting in Static Resource

Is it possible to call javascript remoting in a static resource? I'm creating an AngularJS application, and to stick with best practices I would like to put my services in separate files. Theses ...
23
votes
3answers
5k views

Get file from Lightning input type file

With the Spring 17 release one of the new change on the markup is the introduction of the type file to the lightning:input, however I can't seem to get the file back, only a fakepath with the name of ...
22
votes
3answers
36k views

access controller variable in javascript

Is there any way to access controller variable set in a Method in Javascript. In the example above the value is set in constructor. But when I set it in a method it is showing as NULL in Javascript ...
21
votes
2answers
5k views

What actually happens on re-render?

I would like to know what actually happens on re-render (Ajax Call and DOM replacement) in Salesforce. My Idea: The ajax call is made to get data. On completion of the ajax call, the DOM is ...
20
votes
2answers
61k views

XMLHttpRequest cannot load, No 'Access-Control-Allow-Origin' is present

We have a customer who is having a problem with the embedded visualforce page for their custom objects that include our component. The issue is with the Cirrus_Files_Dog visualforce page. The page is ...
19
votes
3answers
8k views

Feasibility of Angularjs in visualforce pages?

Is it feasible to build visualforce pages with angularjs? Visualforce is itself a MVC framework. It has its own data-binding, data-transfer mechanism through viewstate. If angularjs is used, what ...
18
votes
4answers
4k views

How can I set a date field to null using Visualforce JavaScript Remoting?

Background I've tried to set a Date (and DateTime) field to null using JavaScript Remoting, but I've only succeeded in getting an error message or setting the date to 12/31/1969 6:00 PM. Code Here'...
18
votes
3answers
9k views

Javascript proxies were not generated for the controller: cannot use public remoted methods in Iframe?

I am trying to navigate between a page to another where it uses JsRemoting. When i run the second page alone it works fine. But when i go from first page to another it throws me this kind of error. ...
18
votes
1answer
2k views

Is there a security risk with JavaScript Remoting, escape = false

Initially I thought the answer to this question was yes, so malicious JavaScript cannot be injected into the page if it is in the response. Yet upon a further look at this question it is a lot harder ...
17
votes
3answers
987 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 ...
17
votes
5answers
5k views

Javascript remoting and apex date design pattern

I'd like a clever way to handle this in all my code from now on. I have some existing methods that do date calculations in apex...some use the businessHours object and some don't. Many surface ...
17
votes
4answers
2k views

Best Practice - Lightning JS (Code reuse, testing frameworks and IDE support)

I asked about the difference between controller and helper and it prompted me to ask another, more specific set of questions: What is the best way to reuse JavaScript code across Lightning Components?...
17
votes
2answers
984 views

Sharing JavaScript between multiple Lightning Components

In a Lightning Component we have the notion of a JavaScript controller and a helper. We can use the helper to call code from the JavaScript controller that is shared between functions, so we can ...
17
votes
1answer
10k views

creating a popup panel on a standard detail page layout

We currently use the lead detailed page to display lead information. We have a requirement where we need to create a custom button on the lead detailed page on the standard layout where on clicking ...
17
votes
1answer
1k views

Lightning Components: how to invoke “New Note” panel from custom components?

On the Standard-Related-List "Notes" there is a New Button. This New Button opens a Panel on the bottom of the screen like this: How can I invoke the opening of this "New Note" Panel? I've tried so ...
15
votes
1answer
46k views

How to pass javascript value to controller..?

I want to pass the java-script value to controller.I am using repeat on VF page. VF page <apex:repeat value="{!listAdj}" var="Adj" id="hrs"> <td><div class="requiredInput"&...
15
votes
1answer
4k views

Which external Javascript libraries work with Lightning Locker Service?

Components often seem to work with external libraries until the Locker Service is enabled. What libraries work with locker service enabled and where can I go to find out?
15
votes
5answers
2k views

How to remove standard platform JavaScript from a Visualforce page when it is not needed?

I have an AngularJS app running from a Site that and the main page and partial pages are all wrapped in an apex:page with these attributes: <apex:page showHeader="false" sidebar="false" ...
15
votes
2answers
7k views

How to send Javascript map as a parameter from lightning component to Apex server controller?

I have a lightning component which enqueues server side action. To that action I need to pass a map as one of the parameters, but it looks like it takes memory address of the object instead. The ...
15
votes
1answer
164 views

Would it be a good/bad idea to develop Lightning Components as “Pure Components”?

As a developer, I enjoy playing with different technologies and seeing what I can learn from, and what ideas I might bring back when working on SFDC (my bread and butter). I'm currently looking at ...
14
votes
2answers
4k views

How do I call functions loaded from a Static Resource JavaScript file?

I'd like to put some shared Javascript to Resource file to reuse it between several components. This Javascript is general purpose set of utility functions. However, functions from my resource file ...
14
votes
3answers
8k views

How can I get this apex:repeat variable in javascript?

I have a list of Strings which can be selected or not. When the user clicks save, I need to check which Strings are selected or not from within Javascript. I made an inner class to set a selected ...
14
votes
1answer
3k views

Simple example on how to use Promises to call @AuraEnabled Apex methods?

In the Lightning Component Developer Guide you can find that Promises can be used in Lightning Components and what special things we need to care for to make them work. But there is no fully working ...
14
votes
2answers
3k views

Lightning: is direct API access on the roadmap?

I'm programming developer tools and an IDE. Right now, my code is based on Visualforce and JavaScript. As described here, I would like to convert most of my API callouts form APEX to JavaScript. Also ...
14
votes
1answer
2k views

Access MetadataAPI via JavaScript

We created an 100% native Salesforce IDE as a Managed Package which is using ToolingAPI and MetadataAPI via APEX. This works fine. But there is one thing which really bothers people after the ...
14
votes
2answers
21k views

Browser Error: “Refused to set unsafe header 'User Agent'”

Just today I started having a very odd layout issue on our standard Account layout. The org in on the NA6 server. This is the standard layout. It's always happening when I use chrome. I haven't ...
13
votes
5answers
6k views

How do I set the id of an apex:pageBlockTable row?

I'd like to be able to assign each row in a table an Id so I can easily find the row(s) later using JavaScript. I see where I can set the id of the table but I'd like to also assign an id to each row ...
13
votes
3answers
2k views

What are the advantages/disadvantages of adding JavaScript libraries as a static resource?

I maintain a product on the AppExchange that currently references both JQuery and custom JavaScript that are included in a static resource. Now that I am making some additional updates to the package, ...
13
votes
2answers
920 views

Populate JavaScript array with results from apex methods

If I have two simple apex methods in my controller: public String getStringOne() { String returnStringOne = 'this is the string'; return returnStringOne; } public String getStringTwo() { ...
13
votes
5answers
14k views

How to call Apex REST API from Javascript?

I have two different developer orgs. One contains apex REST web service, and I want to call that REST service from my second org. I have tried to call that REST service using normal ajax post request ...
13
votes
1answer
852 views

Moment JS format returns function string in Lightning Spring 17

I use momentjs's library in my lightning application to manipulate javascript dates. When my sandbox was updated from winter 17 to spring 17 I noticed the format function doesn't work any more. ...
13
votes
1answer
737 views

component.find({ instancesOf : “lightning:input”}) return empty list in Summer '18

With new Summer '18 release following code returns empty list: component.find("social-security-number-form").find({instancesOf : "lightning:input"}) "social-security-number-form" is an aura:id of ...
13
votes
1answer
567 views

Lightning Components: Why is the rendering of 3-level nested <aura:iteration>'s so slow?

I have been working with a nested iteration and it is causing a delay of >3 seconds AFTER loading things from the APEX controller. The APEX response itself is fast, so I'm not looking for any APEX ...
12
votes
4answers
10k views

Winter 17 release : event.getSource is not a function on lightning:button

I'm trying to get the label of the button the user has clicked on by using event.getSource, but I'm getting the error that event.getSource is not a function. Component <lightning:button variant="...
12
votes
1answer
1k views

Is there a version of moment.js that works with the current Locker Service?

I want to reliably find the days between two dates in a Lightning Component and https://momentjs.com/ has this capability. But does it work with the July 2017 Locker Service? This Moment JS format ...
12
votes
3answers
927 views

Salesforce Breaking Javascript Console?

Problem Statement I worked out a neat script to run in the Chrome DevTools console to make a configuration process faster. I went into my sandbox to reproduce the behavior so I could write it up in a ...