Skip to main content
29 votes
Accepted

What is the correct way to pass Parameters to Lightning JS controller from UI:Button?

There is no need for a form in your td. Wrap your button in a div, attach the value to the div via a data- attribute and grab it from the event.currentTarget. Eg: <div onclick="{!c.removeItem}" ...
Caspar Harmer's user avatar
19 votes
Accepted

Define APEX method with default arguments

In some use cases, you might want to consider fluent constructors on classes (or inner classes) public class Foo { Integer bar = 0; // default String fie = 'Hello'; public static Foo ...
cropredy's user avatar
  • 71.9k
17 votes

Content Document download URL params

You can also download multiple files as a zip {!URLFOR('/sfc/servlet.shepherd/version/download/' & delimitedSelectedIdList &'?')} example: {!URLFOR('/sfc/servlet.shepherd/version/download/...
cropredy's user avatar
  • 71.9k
17 votes

Content Document download URL params

Looks like there are some changes recently. I am seeing below pattern with API version 48 For authenticated users /sfc/servlet.shepherd/document/download/06955000001UrOPAA0 For communities /...
Victor's user avatar
  • 3,591
11 votes
Accepted

Passing parameters to a Lightning Component inside a Lightning Tab

There is no direct support for URL parameters in Lightning for components (only apps can receive parameters). Depending on specifics, there are two possible alternatives that might work. For ...
sfdcfox's user avatar
  • 495k
10 votes

Aura: init of child component executes before parent components init, alternate approach?

In Component initialization child component Init event is fired before parent Init event.Use<aura:if> tag to check all required attributes before creating component. <aura:component ...
Arun's user avatar
  • 498
10 votes
Accepted

Pass an enum value from lightning controller to Apex

The types that can be passed are limited, leaving you to have to do more work than ideal sometimes. In this case, code like this should work: @AuraEnabled public static void methodC(String p) { ...
Keith C's user avatar
  • 136k
9 votes

Define APEX method with default arguments

Yes, you have to define method overloads. That is the only way to specify default argument values.
Adrian Larson's user avatar
  • 150k
9 votes
Accepted

How to pass parameter to flow launched from Quick Action

From the input got from Pranay's answer, I was able to launch flow from quick action. I have created a quick action in Account like: Then I created recordId variable in my flow. Using recordId I ...
Reshma's user avatar
  • 4,039
8 votes
Accepted

Loop through ApexPages.CurrentPage().getParameters()

try like this.. ApexPages.CurrentPage().getParameters() return a map . you have to use like below code. for(String param: ApexPages.CurrentPage().getParameters().keyset()) { System.debug('===key==...
Ratan Paul's user avatar
  • 22.7k
7 votes
Accepted

Pass a JavaScript object to Apex controller in lightning

Apex is strongly typed, which means that it has to know in advance what type of data it's dealing with. In this specific case, you could have just passed in an Id: public static void changeProgram(Id ...
sfdcfox's user avatar
  • 495k
6 votes

What is the correct way to pass Parameters to Lightning JS controller from UI:Button?

I think currently recommended by Salesforce way of passing parameters from button to controller is by using event.getSource(). Please note it will work only on Lightning components (for example on ...
Wookie88's user avatar
  • 723
6 votes

What are the risks or drawbacks of creating Parameterized Interfaces using of the Apex API version 25?

Do issues related to instanceof also effect Parameterized types? Yes. The instanceof behavior for these almost certainly has edge cases or areas where there is no defined behavior. Are there ...
ca_peterson's user avatar
6 votes
Accepted

Pass parameters to lightning component from a quick action

As you've discovered, you can get force:hasRecordId. Unfortunately, any other fields you want, you have to query for. The easiest way to query for them is with force:recordData; this automatically ...
sfdcfox's user avatar
  • 495k
5 votes
Accepted

How to get/pass parameter to VF page via JS? How to update field with value from VF page? (updated with BOTH parts)

For 1st Part 1st Method: Create a Button with Onclick Javascript and add the below code in it. {!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")} ...
Subhash's user avatar
  • 1,716
5 votes
Accepted

How to open in lightning experience a custom visualforce page that requires parameters?

This looks to be a namespace issue similar to the one described here - currently in review. It can be reproduced using these steps as mentioned on the link Create an namespace on your Developer ...
Gaurav Kheterpal's user avatar
5 votes
Accepted

RestContext.request.params.get gives null value for Test Class

You need to actually set the RestContext.request in your test class and then set any params you want through that. RestContext.request = new RestRequest(); RestContext.request.params.put('...
Adrian Larson's user avatar
  • 150k
5 votes

What is the correct way to pass Parameters to Lightning JS controller from UI:Button?

The alternative method is to define a new custom component for a row in the table. Make that component have Item as an attribute, then you can read it in the event handler. <aura:component> ...
Aidan's user avatar
  • 13.7k
5 votes
Accepted

Passing parameter in URL in Lightning component tab

Welcome to StackExchange, Gaurav! As of the Summer '18 release, you can use the lightning:isUrlAddressable interface to expose the page URL via the pageReference attribute, like this: Include the ...
Shane Steinfeld's user avatar
5 votes

Why am I getting "Static method cannot be referenced from a non static context: String String.valueOf(Object)"?

The string class's valueOf() method is a static method. Static methods need to be called like this: Class.staticMethodName() i.e. String.valueOf() What you're currently doing is using an instance of ...
Derek F's user avatar
  • 62.4k
5 votes
Accepted

How to pass custom parameters to screen flow in public community?

Okay. I figured this out. Once you have added the flow component to the community page, you need to click on it. In the input you should see your input parameters. In my situation, for the UniqueToken ...
paulK's user avatar
  • 323
4 votes
Accepted

Parameter type as object of custom class

You can. That looks pretty much spot on to me, with the exception of the fact you have to declare the instance variables of your inner class as @AuraEnabled as well.. public class Person{ @...
Simon Lawrence's user avatar
4 votes
Accepted

Passing parameters with different names and treating it as one

You could also just use a conditional expression <apex:page controller="MyController" language="{!Blankvalue($currentpage.parameters.lang, $currentpage.parameters.language) }"> </apex:page&...
Eric's user avatar
  • 54.2k
4 votes
Accepted

Passing a parameter to batchable class

The typical way to do this is to write a constructor, and place the desired variables into your class. Here's the minimum changes you could make: global class batchableClassName implements Database....
sfdcfox's user avatar
  • 495k
4 votes
Accepted

How to reference parameters outside of Apex Class that can be configured by Administrator

Is this an optimal way of doing this or is there a better way to accomplish this (with similar or greater advantages)/Would it be better to use a Custom Metadata Type for this scenario? I would use ...
Pranay Jaiswal's user avatar
4 votes
Accepted

When LWC invokes a function, is it possible for the function to access arbitrary attributes in the invoking element?

Your widget-tile component can include the widget passed in to it: @api widget; dispatchWidgetSelectEvent() { this.dispatchEvent( new CustomEvent('widgetselect', { detail: { widget } }) ...
sfdcfox's user avatar
  • 495k
4 votes
Accepted

Special Characters in rest API URL

Yes, you have to escape it, basically you use the method escapeHtml4() of the class String. String s1 = '"<Mom&Dad>"'; String s2 = s1.escapeHtml4(); System.debug(s2); // ...
mario ruiz's user avatar
4 votes
Accepted

Passing a method as parameter from a parent LWC to a chil LWC

Inside a component's markup, the on prefix is reserved for event handlers (e.g. you can't declare a variable called onsuccess). Inside the component that is dispatching the event, you'll find code ...
sfdcfox's user avatar
  • 495k
3 votes
Accepted

How to pass parameters from a VF page to a controller extension

Main Issue: No rerender on the action function. Removing that produces an attempt to dereference null object. SO I essentially added that to the actionFunction and it all started to work. Issue has ...
Eric's user avatar
  • 54.2k
3 votes

How can I pass input parameters into a hyperlink?

Here's an approach - no controller code required Use apex:actionSupport to transmit change in batchDate to controller and refresh the commandButton Use URLFOR and especially the third argument to ...
cropredy's user avatar
  • 71.9k

Only top scored, non community-wiki answers of a minimum length are eligible