Skip to main content
6 votes
Accepted

put an image in a command button

You can store the required image in static resource and use it in command button in the following way <apex:commandbutton image="{!URLFOR($Resource.Required_Image)}" id="SaveChanges" reRender="...
Sukesh Kumar's user avatar
6 votes
Accepted

Passing Parameters Commandbutton

Need to be add a DummyID for reRedner. <apex:page controller="clicktest"> <apex:form> <apex:commandButton action="{!Stats_In}" value="click" reRender="dummyId"> <...
NITHESH K's user avatar
  • 2,535
6 votes
Accepted

How to disable a apex command button

You should set the btnDisabled class name, as well as setting "disabled". Here's a live example for you to use: <apex:page standardStylesheets="true" lightningStylesheets="false" showHeader="true" ...
sfdcfox's user avatar
  • 497k
5 votes
Accepted

CommandButton with JavaScript and controller method

Make the variable "doc" static to avoid view state error
Anurag's user avatar
  • 2,236
5 votes
Accepted

How to call apex method from command button on custom visualforce page

You can't specify parameters as you would when calling a method directly from Apex Code. Instead, you have to use apex:param, as shown here: <apex:commandButton action="{!sendEmail}" value="Send ...
sfdcfox's user avatar
  • 497k
5 votes
Accepted

Embedded VF page's refresh issue

No, that's expected. In fact, this probably shouldn't work at all, because you're prematurely cancelling the actionFunction (it's asynchronous). What you end up with is a situation that's a race ...
sfdcfox's user avatar
  • 497k
5 votes

How can I get this button to pass data to controller?

Take a look at the apex:actionFunction. This allows you to generate a JavaScript function and to call this function from JavaScript in your page (e.g. in an onclick event). The parameters to the ...
Phil W's user avatar
  • 37k
4 votes
Accepted

Align a command button using float:center style

There's no such CSS value for "float" of "center." If you want your commandButton to be in the middle of the area, you should do something like this: <div style="text-align: center"> <...
sfdcfox's user avatar
  • 497k
4 votes
Accepted

Make a button on visualforce update the records in an object

If these are all fields that live directly on your custom object, then you can just use the standard controller on your custom object, and then invoke the standard {!save} function on a commandButton/...
Morgan Marchese's user avatar
4 votes
Accepted

commandbutton on a vf page inside a section

Change your javascript function name from new() to something else say new_method() as new is a keyword. It will work.
s_saiyan's user avatar
  • 530
4 votes
Accepted

Unintended Page refresh command button inside form

use reRender attribute on apex:commandButton here is a nice article Implementing Partial Page Updates with Command Links and Buttons where all required steps are listed First, create or identify the ...
Oleksandr Berehovskyi's user avatar
3 votes
Accepted

Problem in reRender of <apex:detail> tag on click of commandbutton

It's look like inlineEdit couldn't be binded with dynamic boolean. Try to create two detail and render them accordingly: <apex:tab label="Details" name="AccDetails" id="tabdetails"> <...
Ilya Lepesh's user avatar
  • 4,125
3 votes
Accepted

Making a command button open in new tab

You can try with a CommandLink as: <apex:commandLink target="_blank" styleClass="btn" style="text-decoration:none;padding:4px;" action="https://c.eu6.visual.force.com/apex/AmountSpent2?core....
C. Praveenkumar's user avatar
3 votes

Is there a apex command button that allows you to not refresh the page?

Ok, there are a couple of things going on here: When you include merge syntax in javascript they do not get updated when the properties in the controller get updated unless you rerender them. When I ...
Eric's user avatar
  • 54.2k
3 votes
Accepted

Using action and onclick together on command button

If you want to abort the action, return a value. If you do not want to abort the action, do not return a value. Example: <apex:commandButton value="Do Something" onclick="if(!...
sfdcfox's user avatar
  • 497k
3 votes

System.QueryException: unexpected token: = Error is in expression '{!dosearch}' in component

you have problem with string query. Do not use string for SOQL query, until you have to do it, because dynamic SOQL is vulnerable to SOQL Injections. There are two ways to prevent possible SOQL ...
Oleksandr Berehovskyi's user avatar
3 votes
Accepted

Only allow one submission with apex CommandButton

I am assuming that your apex:commandbutton is within an apex:form, note that an apex:commandbutton reders to: <input id="thePage:theForm:theButton" type="submit" name="thePage:theForm:theButton" ...
glls's user avatar
  • 20.2k
3 votes
Accepted

CommandButton oncomplete JS function not firing

The following works in my testing: <apex:commandButton value="Reject (Entry Criteria)" onclick="if(!confirm('Are you sure?')){return false};" action="{!debugSomething}" oncomplete="refreshPage();"...
Eric's user avatar
  • 54.2k
3 votes
Accepted

How to detect which command button is clicked?

You can pass the parameter in the Javascript function and then check the value for both the case. For example Pass Save from the save button and pass SaveAndNew from save and new button. Below will ...
Amit Singh's user avatar
3 votes
Accepted

Visualforce CommandButton Open in Existing Window

Add target to the parent tag, as you can see the following code i have added to the <apex:form>, i have tested and it's working <apex:page standardController="Account" > <apex:form ...
Narendra Nimmana's user avatar
3 votes

Displaying a list returned from a method on a Visualforce page

Apex is a case-insensitive language. The identifiers pgm and PGM are the same as far as the compiler is concerned. In addition, there is a key logical error in the code populating this variable. Let's ...
David Reed's user avatar
  • 93.2k
3 votes
Accepted

How to include Find Duplicates standard button in visualforce page

As per VF developer guide it would be FindDup <apex:commandButton action="{!URLFOR($Action.Lead.FindDup, Lead.Id, null, true)}" value="FindDup" />
Pranay Jaiswal's user avatar
3 votes

Lightning cancel button in visualforce page

Method - Using html-5 in doctype in visualforce page means you should use html-formnovalidate and immediate in cancel button. For example <apex:commandButton action="{!cancel}" value="Cancel" ...
Sahil Malhotra's user avatar
2 votes
Accepted

How to create New custom button of Quote for create New Quote Using URL Hack

You can not leave Opportunity as a blank just because of both object have Master-Detail Relationship. Alternate solution is : Create one Visualforce and set that page in your new Custom button ...
Nihar's user avatar
  • 1,182
2 votes

URL hack is not working for Standard Quote Object Using custom button (Visualforce page)

We have to provide the Id of the Opportunity since Opportunity and Quote is a Master-detail relationship. We cannot make the opportunity to be blank.
Nihar's user avatar
  • 1,182
2 votes

How to add a field in Salesforce using Standard field Types/using Visualforce, so that we can Attach a file from Computer with it?

There is not a specific field type that you can use for this. It is possible to attach a file to a record using Visualforce page with a custom Apex controller which will allow the user to browse the ...
Dave Humm's user avatar
  • 5,111
2 votes

Posting data to a controller extension method

Unless you are using JS remoting you need to use class properties: public string activationId {get; set;} public string userName {get; set;} public string password {get; set;} public static Boolean ...
Eric's user avatar
  • 54.2k
2 votes
Accepted

Posting data to a controller extension method

In your controller, you need a class method that returns a PageReference in order to associate it to the commandButton. You'll also want to have some class variables to bind the input fields to: ...
IllusiveBrian's user avatar
2 votes
Accepted

Is there a way to hide the "Save And Submit" button after the record is saved?

All you need to do is rerender the buttonPanel since you already have a flag to indicate it has been saved. Ensure you have set inSubmissionProcess to true in your controller or add a new flag to ...
Eric's user avatar
  • 54.2k
2 votes
Accepted

Hide custom button on visualforce page

You can use rendered attribute in apex:commandButton like below: <apex:commandButton value="Confirm" action="{!Confirm}" rendered="{!ishide}"/> Modified the class like below by using an extra ...
Subhasis Kar's user avatar

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