Skip to main content
6 votes
Accepted

Possible to call a javascript and action function from click

Yes, you can. You can use the onclick attribute like below. <apex:commandButton value="Search" action="{!objectCollection}" onclick="callJSFunc()" style="margin-left:10px" reRender="...
smukov's user avatar
  • 5,613
6 votes
Accepted

Cannot read property 'value' of null in this case

In this case, it was a simple typo: the ID value is cAsE-sEnSiTiVe. alert('called' + document.getElementById("thepage:theform:atextId").value); // ^ ...
sfdcfox's user avatar
  • 497k
5 votes
Accepted

Adding One Year to Date Field Value Through Custom Button

It would look something like this: {!requireScript("/soap/ajax/37.0/connection.js")} var newRecords = []; var c = new sforce.SObject("Invoice_Statement__c"); c.id = "{!Invoice_Statement__c.Id}"; c....
sfdcfox's user avatar
  • 497k
5 votes

Action failed: lightning:button$controller$handleClick [d.run is not a function]

In my case I was missing the exclamation point in action in the component definition: incorrect: onclick = "{ c.someEvent }" correct: onclick = "{! c.someEvent}"
AndrewW's user avatar
  • 51
4 votes
Accepted

How to get all buttons in my page from a controller javascript function(component, event, helper)?

Add an aura:id to the <ui:button /> component, then find the button by it. component: <ui:button aura:id="btn" label="A" press="{!c.disableMe}"/> <ui:button aura:id="btn" ...
Praveen's user avatar
  • 10.1k
4 votes
Accepted

Refresh Page After OnClick

This functionality works for me. If I include the below Visualforce Page in a Page Layout and click the button, it refreshes the whole page. <apex:page standardController="Case"> <apex:...
Adrian Larson's user avatar
  • 151k
4 votes
Accepted

Confirm Dialog Box On Detail Page

There is no exact and simple solution for this OK and CANCEL in Confirm Popup using javascript. But you can do this with the help of JQUERY. Try the below link to understand better... https://...
Subhash's user avatar
  • 1,716
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

Visualforce: Checkbox is not firing function onclick

The problem is reported in the console: Uncaught TypeError: checked is not a function It seems to be a name conflict but I can't see where. Changing the function name to e.g. isChecked works ...
Keith C's user avatar
  • 136k
4 votes

Visualforce: Checkbox is not firing function onclick

The first thing you should always do when you face a Javascript error is open up the console. Here's how to do it on: Chrome Firefox Opera Safari IE If you had done so, you would have seen the ...
Adrian Larson's user avatar
  • 151k
4 votes
Accepted

How to detect showListButton/hideListButton being clicked on collapsible PageBlockSection?

Caution This code relies on the internal library, and so may break at any time. Use at your own risk. Basically, you can override the default method, which will allow you to do something based on ...
sfdcfox's user avatar
  • 497k
4 votes
Accepted

Aura Iterate, get the aura:id of a span

When you're using normal HTML, you have a lot of flexibility in what you do with this. One solution not involving the use of id is to set a data attribute on the span: <aura:component> <...
sfdcfox's user avatar
  • 497k
3 votes

Adding onclick to dynamically created button

I just did something like this the other day. Not sure if it meets all your needs but it at least illustrates the concept Component Controller ({ doinit: function(component,event,helper){ <...
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
Accepted

Validating sObject fields in JavaScript Custom Button?

Replace: var currentProjectPhase = {!project_cloud__Project__c.Current_Project_Phase__c}; With: var currentProjectPhase = "{!project_cloud__Project__c.Current_Project_Phase__c}"; Also: if (...
Yonathan Goriachnick's user avatar
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

OnClick Javascript button error when merge field value is "St. John's"

You forgot the quotes on the outside: var encoded = "{!JSENCODE("St. John's")}"; This would render as: var encoded = "\"St. John\'s\"";
sfdcfox's user avatar
  • 497k
3 votes
Accepted

press and hold mouse event in LWC

onmousedown and onmouseup only trigger when a button is pressed or released, respectively. Unlike some keyboard events, they do not repeat periodically. It is therefore up to you to determine when/how ...
sfdcfox's user avatar
  • 497k
3 votes

Change text & prevent double click of LWC button

Here's a similar scenario which I tried. We just need to bind the label , disabled property of lightning-button to a js variable in LWC. Below is the lightning-button which has label & disabled ...
Rohit's user avatar
  • 2,091
3 votes
Accepted

LWC - render component onclick event

Date is an object, not a primitive, so this.date holds a reference, therefore its value doesn't change when you run setDate(). That's why the framework doesn't rerender it. Reactivity for Fields, ...
RubenDG's user avatar
  • 8,752
2 votes

OnClick Javascript attached to Custom button not working correctly

Your condition: if(!("{!Animal__c.RecordType}" != "2 – Invoice" || "{!Animal__c.Invoice_Status__c}" != "Credited")) will be executed only if condition inside parenthesis is false, meaning that both ...
Ilya Lepesh's user avatar
  • 4,125
2 votes
Accepted

If statement fails in Onclick javascript button

Can you please try below code, if the check value is coming as true from check=sforce.apex.execute("CheckAOCAccess","AOCAccess",{LoggedUser:"{!User.Id}"}); if(check=='true'){ // This line fails to ...
RCS's user avatar
  • 2,108
2 votes
Accepted

Uncaught ReferenceError: callAF is not defined

Give your apex:param name attribute. So it will work. <apex:actionFunction name="callAF" action="{!checkActive}" reRender="pbt"> <apex:param name="apparam" id="accId" value="" assignTo="{!...
Tushar Sharma's user avatar
2 votes
Accepted

Invalid left hand side in custom Javascript

I always recommend evaluating your conditions within the merge field, which reduces the probability of errors. Here's a revised if statement: if({!NOT(ISPICKVAL(Quote.Status,'Cancelled'))&& ...
sfdcfox's user avatar
  • 497k
2 votes
Accepted

On-Click Button: Why is Salesforce passing in 'undefined' string value?

The GetRecordIds formula literally does what it says: it gets the list of Id values the user selected. If you want the account names, you have to use sforce.connection.retrieve or sforce.connection....
sfdcfox's user avatar
  • 497k
2 votes
Accepted

How can I reference an installed pkg VF page in an OnClick Javascript Detail Button

Your code doesn't need the server name, $Page, or URLFOR; both your browser and the Service Console accepts relative URLs, so this code should work: {!REQUIRESCRIPT("/support/console/30.0/integration....
sfdcfox's user avatar
  • 497k
2 votes
Accepted

Updating a record, and related record using a custom button

Your entire code is correct, the only thing you are missing is you are not getting opportunity Id in your query. You have to explicitly get the Opportunity id. Use below query. Everything else is fine....
salesforce Developer's user avatar
2 votes
Accepted

Making a checkbox field value null using a JS function

Checkboxes have a "value", but that's the value submitted to the server (it default to "on" when checked, and nothing otherwise), but to actually modify its checked state, you need to use checked: ...
sfdcfox's user avatar
  • 497k
2 votes
Accepted

Update controller variable from visualforce button/div onclick

Add the rerender property to the apex:actionFunction tag. in the rerender property you want to add the ID of the tag you want to rerender. That way the page won't refresh it will just rerender the ...
Dan Kowalski's user avatar
2 votes

lightning dynamic component datatable onclick/onrowselection

If you read the component documentation for the Lightning:datatable you might notice that onclick is not a supported attribute. When creating lightning components, if you declare unsupported ...
glls's user avatar
  • 20.2k

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