• WHO WE ARE
  • WHAT WE DO
    • Salesforce
      • Implementations
        • Sales Cloud
        • Service Cloud
        • CPQ
        • Field Service Lightning
        • Field Service for SMEs
      • Developments
        • Salesforce Customization
        • Custom Application Development
        • AppExchange Product Development
      • Migrations
        • Classic to Lightning Migration
        • Other Systems to Salesforce Migration
      • Integrations
    • Data Science
      • BI Solutions
      • AI/ML solutions
      • Agentic AI
  • HOW WE DO
    • Delivery Model
    • Our Works
  • REACH US
    • Contact Us
    • Careers
  • BLOG
    • WHO WE ARE
    • WHAT WE DO
      • Salesforce
        • Implementations
          • Sales Cloud
          • Service Cloud
          • CPQ
          • Field Service Lightning
          • Field Service for SMEs
        • Developments
          • Salesforce Customization
          • Custom Application Development
          • AppExchange Product Development
        • Migrations
          • Classic to Lightning Migration
          • Other Systems to Salesforce Migration
        • Integrations
      • Data Science
        • BI Solutions
        • AI/ML solutions
        • Agentic AI
    • HOW WE DO
      • Delivery Model
      • Our Works
    • REACH US
      • Contact Us
      • Careers
    • BLOG
  • [email protected]
  • (+91) 44-49521562
Merfantz - Salesforce Solutions for SMEs
Merfantz - Salesforce Solutions for SMEs
  • WHO WE ARE
  • WHAT WE DO
    • Salesforce
      • Implementations
        • Sales Cloud
        • Service Cloud
        • CPQ
        • Field Service Lightning
        • Field Service for SMEs
      • Developments
        • Salesforce Customization
        • Custom Application Development
        • AppExchange Product Development
      • Migrations
        • Classic to Lightning Migration
        • Other Systems to Salesforce Migration
      • Integrations
    • Data Science
      • BI Solutions
      • AI/ML solutions
      • Agentic AI
  • HOW WE DO
    • Delivery Model
    • Our Works
  • REACH US
    • Contact Us
    • Careers
  • BLOG

What is the Purpose of AJAX component in Salesforce

  • August 1, 2017
  • Merfantz Editor
  • Salesforce Developments Tutorial
  • 0

This post is beneficial to you if you faced some user interface level requirement. Here we explained about the actionFunction tag. We move on the first step what it is.

ActionFunction:–

This is one of the AJAX support components in visual force page. This should be contained on parent tag like that apex: form tag. The main use of the actionfunction to calling a method from visual force to apex class through javascript.

Without using actionfunction, you can call a method to apex class it is possible by using the button with action attribute. Why we used this? Some time we need javascript support for User Interface, without button click. Here we used one example contains a checkbox for customer confirmation before insertion.

Syntax :-

<apex:actionFunction name=”Javascript-Returning-Function-Name” action=”{!Apex-Method-Name}”/>

For examples, Customer try to booking in Hotel, it will check the customer confirmation then it will inserted into the database by using checkbox.

Try the below code :-

JS method name – jsconfirm

JS return method name – jsresult

apex method name – booking

Visulforce code

<apex:page controller=”ActionFunctionController” sidebar=”false” id=”pg”>

<apex:form id=”frm”>

<apex:actionFunction name=”jsresult” action=”{!booking}” reRender=”con”/>

<table>

<tr>

<td>Booking Customer :</td>

<td><apex:inputText id=”tt” value=”{!txt}”/></td>

</tr>

<tr>

<td>Click this box</td>

<td><apex:inputCheckbox onclick=”jsconfirm()” id=”chkbox”/></td>

</tr>

</table>

<br/>

<apex:outputLabel value=”{!confirmationtext}” id=”con”></apex:outputLabel>

</apex:form>

<script type=”text/javascript”>

function jsconfirm(){

var c=document.getElementById(‘pg:frm:tt’).value;

if(c!=”){

var a=confirm(‘Are you sure to booking ? …’);

if(a==true){

jsresult();

}

}

else{

alert(‘Please fill the customer name’);

}

}

</script>

</apex:page>

Apex Class :-

public class ActionFunctionController{

public String confirmationtext{set;get;}

public String txt{set;get;}

public void ActionFunctionController(){}

public void booking(){

Hotel__c h=new Hotel__c();

system.debug(txt);

h.Booking_Customer__c=txt;

insert h;

confirmationtext=’You are booking success full’;

}

}

Result :-

This the starting page,

Click checkbox the error showing if you did not enter customer name,

Click checkbox the confirmation showing after you entered information,

 

Click ok then it will pop up success message and record added in your object.

We are the ISV Partners and Please reach us for custom development => www.merfantz.com

———————– We hope this it will help to you ———————






Author Bio

Merfantz Editor
+ Recent Posts
  • August 4, 2023
    How to Setup CRM Analytics for Financial Services Cloud
  • August 2, 2023
    How to Get Started with Salesforce Hyperforce - Merfantz
  • July 28, 2023
    Health Cloud Mastery: Salesforce Trailhead for Effective Healthcare CRM
  • July 26, 2023
    How to integrate Data cloud and Marketing cloud In Salesforce
Tags: Field Service ManagementFieldax
  • Previous How to Access Multiple Record from One Record Creation/Updation in Salesforce
  • Next What is the Purpose of apex:actionsupport of AJAX Component in Salesforce

Leave a Reply

You must be logged in to post a comment.

Merfantz Technologies is a leading Salesforce consulting firm dedicated to helping small and medium enterprises transform their operations and achieve their goals through the use of the Salesforce platform. Contact us today to learn more about our services and how we can help your business thrive.

Discover More

Terms and Conditions
Privacy Policy
Cancellation & Refund Policy

Contact Info

  • No 96, 2nd Floor, Greeta Tech Park, VSI Industrial Estate, Perungudi, Chennai 600 096, Tamil Nadu, INDIA
  • (+91) 44-49521562
  • [email protected]
  • 9:30 IST - 18:30 IST

Latest Posts

Comprehensive Overview of Salesforce Agent-Force Platform
Comprehensive Overview of Salesforce Agent-Force Platform June 12, 2025
Salesforce GraphQL Revolutionizing Data Queries in CRM
Salesforce GraphQL: Revolutionizing Data Queries in CRM June 6, 2025
Unlocking the Power of Dynamic Forms in Salesforce Lightning App Builder
Unlocking the Power of Dynamic Forms in Salesforce Lightning App Builder May 29, 2025

Copyright @2023 Merfantz Technologies, All rights reserved