Salesforce Tutorial – Create Simple Ajax based Visualforce page

Salesforce Tutorial – Step by step tutorial to create AJAX based application in visualforce page with Apex class

Hello friends,
This time i am going to create very simple AJAX based visual force page for the beginners.

What is AJAX?

As many of you already know that the AJAX stands for the “Asynchronous javascript and XML“.

AJAX is the art of exchanging data between server and client without reloading the complete web page.

Visualforce and AJAX

Visualforce has inbuilt support for the AJAX. using the attribute “rerender” we can specify that where the response should be rendered. Continue reading “Salesforce Tutorial – Create Simple Ajax based Visualforce page”

Create a custom Web service in Salesforce and consume it in C#.Net application

In this tutorial, we will create the web service in salesforce and consume it in c#.Net application

In Previous article, we have consumed the standard enterprise wsdl of the salesforce. In this article we will create the webservice using apex in salesforce and consume it in C#.Net application.

In Salesforce create below class (using IDE)

global public with sharing class SaveExpenditureWebService {

	webservice static Expenditure__c createExpenditure(Decimal amount,String expName, String paidByName )
		Expenditure__c c = new Expenditure__c();
		Person__c p = [Select p.Name From Person__c p Where Name = :paidByName limit 1];
		c.Amount__c = amount;
		c.Name = expName;
		c.Exp_Date__c =;
		c.Paid_By__c = p.Id;
		insert c;

		return c;


  • Apex class in which webservice is going to be written must be declared “global“.
  • Keyword “webservice“ must be used for a method which should be exposed as a webservice.
  • Method must be declared as static.

In above code, I am using a custom object “Expenditure__c“ to insert into Salesforce.  Any type of code can be written.
Now in C#, create windows application with following controls:

Create Custom web service in salesforce using apex and consume using C#.Net
Create Custom web service in salesforce using apex and consume using C#.Net

Continue reading “Create a custom Web service in Salesforce and consume it in C#.Net application”

Salesforce Interview Questions – Part 3

Author posted by Jitendra on Posted on under category Categories Salesforce and tagged as Tags , , with 30 Comments on Salesforce Interview Questions – Part 3

Most Frequently Asked interview questions of Apex, Visual force, SOQL in SFDC

20. In Which sequence Trigger and automation rules run in

Ans : The following is the order Salesforce logic is applied to a record.

  1. Old record loaded from database (or initialized for new inserts)
  2. New record values overwrite old values
  3. System Validation Rules
  4. All Apex “before” triggers
  5. Custom Validation Rules
  6. Record saved to database (but not committed)
  7. Record reloaded from database
  8. All Apex “after” triggers
  9. Assignment rules
  10. Auto-response rules
  11. Workflow rules
  12. Escalation rules
  13. Parent Rollup Summary Formula value updated (if present)
  14. Database commit
  15. Post-commit logic (sending email)

Additional notes: There is no way to control the order of execution within each group above.

21. If one object in Salesforce have 2 triggers which runs “before insert”. Is there any way to control the sequence of execution of these triggers?

Ans : has documented that trigger sequence cannot be predefined. As a best practice create one trigger per object and use comment blocks to separate different logic blocks. By having all logic in one trigger you may also be able to optimize on your SOQL queries.

22. How to delete the User from Salesforce?

Ans : As per now, salesforce does not allow to delete any user, however you can deactivate the user.

Read further…

23. How to delete the users data from Salesforce?

Ans : To delete the Users Data go to Setup | Administration Setup | Data Management |  Mass Delete Record, from there select the objects like Account, Lead etc and in criteria select the users name and delete all records of that user related to particular object.

24. How to restrict the user to see any record, lets say opportunity?

Ans : set up opportunity sharing to be private.  If both users are admins or have view all records on opportunity, then that overrides private sharing.

25. What is the difference between and trigger.old in Apex – SFDC?

Ans : :

Returns a list of the new versions of the sObject records.

Note that this sObject list is only available in insert and update triggers, and the records can only be modified in before triggers.

Trigger.old :

Returns a list of the old versions of the sObject records.

Note that this sObject list is only available in update and delete triggers.

26. How to restrict any Trigger to fire only once OR how we can avoid repeated or multiple execution of Trigger?


Triggers can fire twice, once before workflows and once after workflows, this is documented at Content/ apex_triggers_order_of_execution.htm:

“The before and after triggers fire one more time only if something needs to be updated. If the fields have already been set to a value, the triggers are not fired again.”


Add a static boolean variable to a class, and check its value within the affected triggers.

public class HelperClass {
   public static boolean firstRun = true;
trigger affectedTrigger on Account (before delete, after delete, after undelete) {
                Trigger.old[0].addError('Before Account Delete Error');

27.  What is difference between WhoId and WhatId in the Data Model of Task ?

Ans :

WhoID refers to people things. So that would be typically a Lead ID or a Contact ID
WhatID refers to object type things. That would typically be an Account ID or an Opportunity ID

Check Data Model of task here

28. Where is the option of the report for the “Custom Object with related object” and what are the condition to generate related reports?
Ans :

If the parent object is the standard object provided by the salesforce like “Account”, “Contact” then the report will be in there section with related custom object.
If both objects are the custom then the report will be in “Other Reports” Sections.

Following are the conditions to get the report of related objects:

  • On both the objects, Reports option must be enable.
  • Both object must be related either using Lookup or Master Detail type of field.

Read this article, to get detailed idea on this topic.

29. How you can provide the User Login (Authentication) in Public sites created by Salesforce.

Answer : We can provide the authentication on public sites using “Customer Portal”.