পৃষ্ঠাসমূহ

Search Your Article

CS

 

Welcome to GoogleDG – your one-stop destination for free learning resources, guides, and digital tools.

At GoogleDG, we believe that knowledge should be accessible to everyone. Our mission is to provide readers with valuable ebooks, tutorials, and tech-related content that makes learning easier, faster, and more enjoyable.

What We Offer:

  • 📘 Free & Helpful Ebooks – covering education, technology, self-development, and more.

  • 💻 Step-by-Step Tutorials – practical guides on digital tools, apps, and software.

  • 🌐 Tech Updates & Tips – simplified information to keep you informed in the fast-changing digital world.

  • 🎯 Learning Support – resources designed to support students, professionals, and lifelong learners.

    Latest world News 

     

Our Vision

To create a digital knowledge hub where anyone, from beginners to advanced learners, can find trustworthy resources and grow their skills.

Why Choose Us?

✔ Simple explanations of complex topics
✔ 100% free access to resources
✔ Regularly updated content
✔ A community that values knowledge sharing

We are continuously working to expand our content library and provide readers with the most useful and relevant digital learning materials.

📩 If you’d like to connect, share feedback, or suggest topics, feel free to reach us through the Contact page.

Pageviews

Wednesday, January 25, 2017

Apex - Invoking

Apex invoking refers to the process of executing the Apex class. Apex class can only be executed when it is invoked via one of the below ways:
  • Triggers and Anonymous block
  • A trigger invoked for specified events.
  • Asynchronous Apex
  • Scheduling an Apex class to run at specified intervals, or running a batch job.
  • Web Services class
  • Apex Email Service class
  • Apex Web Services, which allow exposing your methods via SOAP and REST Web services.
  • Visualforce Controllers
  • Apex Email Service to process inbound email.
  • Invoking Apex Using JavaScript
  • The Ajax toolkit to invoke Web service methods implemented in Apex.
We will have look at some common way to invoke Apex.

From Execute Anonymous Block

You could invoke the Apex class via execute anonymous in Developer console as shown below:
Step 1: Open Developer Console
Step 2: Click on Debug.
apex_invoking_from_execute_anonymous_Step_1 Step 3: Execute anonymous window will open as shown below and click on execute button:
apex_invoking_from_execute_anonymous_Step_2 Step 4: Open Debug Log when it will appear in Logs pane.
apex_invoking_from_execute_anonymous_Step_3

From Trigger

You could call an Apex class from Trigger as well. Triggers are called when a specified event occurs and triggers can call the Apex class when executing.
Below is the sample code that shows how a class gets executed when a Trigger is called.
Example:
//Class which will gets called from trigger
public without sharing class MyClassWithSharingTrigger {
    
    public static Integer executeQuery (List<apex_customer__c> CustomerList) {
        //perform some logic and operations here
        Integer ListSize = CustomerList.size();
        return ListSize;
    }
}

//Trigger Code
trigger Customer_After_Insert_Example on APEX_Customer__c (after insert) {
    System.debug('Trigger is Called and it will call Apex Class');
    MyClassWithSharingTrigger.executeQuery(Trigger.new);//Calling Apex class and method of an Apex class
}

//This example is for reference, no need to execute and will have detail look on triggers later chapters.

From Visualforce Page Controller Code

Apex class can be called from Visualforce page as well. We can specify the controller or controller extension and the specified Apex class gets called.
Example:
VF Page Code:
apex_invoking_from_vf_page_Step_1 Apex Class Code (Controller Extension)
apex_invoking_from_vf_page_Step_2

No comments:

Post a Comment