Skip to main content

Visualforce actionFunction Component

About Us
Published by admin
11 May 2015
10282

ActionFunction is a component, which provides support for invoking controller action methods directly from JavaScript code with the use of AJAX request.

An <apex:actionFunction> component must be a child of an <apex:form> component.

Unlike <apex:actionSupport>, which only provides support for invoking controller action methods from other Visualforce components, <apex:actionFunction> defines a new JavaScript function which can then be called from within a block of JavaScript code.

Beginning with API version 23 you can't place <apex:actionFunction> inside an iteration component — <apex:pageBlockTable>, <apex:repeat>, and so on. Put the <apex:actionFunction> after the iteration component, and inside the iteration put a normal JavaScript function that calls it.

If we want to use actionFunction, the first step is setting off a name (name=”MyActionFunction”). It is the only required attribute in this component. When we want to call our function, we call it by name.

Next step is to set action. The action method is invoked when the actionFunction is called by a DOM event elsewhere in the page markup. Use merge-field syntax to reference the method. For example, action="{!save}" references the save method in the controller. If an action is not specified, the page simply refreshes.

Attribute rendered can be used to activate or to deactivate your actionFunction. You can use a formula here.

Attribute reRender helps us to update only chosen (by id) parts of the page when the action is completed.

With help of oncomplete it is possible to set, what will happen next.

The JavaScript is invoked when the onbeforedomupdate event occurs – that is when the AJAX request has been processed, but before the browser's DOM is updated.

In the timeout we can set the amount of time (in milliseconds) before an AJAX update request should time out.

Attribute namespace helps you to set necessary namespace for your function, but if this attribute is not added, the namespace will be generated automatically.

Like in most other components, you can set id for your actionFunction and allow the actionFunction component to be referenced by other components in the page.

In focus attribute you can put the ID of the component that is in focus after the AJAX request completes.

Attribute status is the ID of an associated component that displays the status of an AJAX update request.

Setting immediate="true" we can specify whether the action associated with this component should happen immediately, without processing any validation rules associated with the fields on the page.

<!-- Page: -->

visualforce

/*** Controller ***/

visualforce


image
Question to the expert
image

We have available resources to start working on your project within 5 business days

1 UX Designer

image

1 Admin

image

2 QA engineers

image

1 Consultant

image
Related Articles
All articles
image
Is Salesforce Winning the Public Sector Race?
An analysis of Salesforce's rapid expansion into the U.S. public sector, tracing its path from cautious early government licensing deals in the 2010s through the launch of Government Cloud in 2012, its pivotal role in COVID-19 vaccine rollouts, and its 2025–2026 push into military and intelligence work via Agentforce and Missionforce. The piece covers major 2026 contracts — including a $5.6 billion Army deal, a $1.6 billion VA agreement, and Pentagon Impact Level 5 authorization — alongside real-world case studies like California's REAL ID processing and the UK's NHS back-office operations. It also examines the structural obstacles still facing Salesforce and other vendors in government tech: legacy IT systems decades old, outdated federal procurement rules, budget constraints, and organizational caution around AI adoption, plus the competitive pressure from Palantir, Microsoft, and Oracle in the race for public sector AI spending.
28 August 2026
image
Why Your Salesforce Flows Are Agentforce's Biggest Problem
This article argues that the most underestimated risk in Agentforce deployments isn't data quality — it's the automation layer: years of overlapping Flows, Process Builder processes, Apex triggers, and managed package logic that no one has reviewed end-to-end. It explains why AI agents inherit automation complexity without the tribal knowledge human admins carry, why technical debt only becomes visible after an agent hits it in production, and why a clean demo is no indicator of production readiness. The article closes with a concrete, tool-by-tool inventory approach using Flow Trigger Explorer, Salesforce Optimizer, Setup Audit Trail, Apex Debug Logs, Agent Builder, and Health Check — scoped to the specific processes the agent will actually use rather than the whole org.
23 July 2026
image
How to Wire Multiple Salesforce Projects in One Org Without Breaking Everything
This article maps the real integration patterns that emerge when multiple Salesforce projects — both managed packages and unpackaged code — share a single org. It covers four concrete patterns: attaching custom triggers to package-owned objects, calling global members exposed by managed packages, writing directly into another project's objects, and runtime-guarded reads of package data. It then addresses access control for authenticated and guest users, including the Master-Detail wall and the without sharing elevation pattern. The piece closes with eight concrete risks (compile-time dependencies that block uninstall, upgrade coupling, silent cascade failures, access invisible to admins) and six actionable recommendations for keeping cross-project coupling manageable.
08 July 2026