When working with small amounts of data, use the AJAX
Toolkit.
AJAX works best with relatively small amounts of data (up to
200 records, approximately six fields with 50 characters of data each). The
larger the data set returned, the more time it will take to construct and
deconstruct a SOAP message, and as the size of an individual record gets
larger, the impact on performance becomes greater. Also, as more HTML nodes are
created from the data, the potential for poor performance increases. Because
browsers are not efficient, careful consideration needs to be given to browser
memory management if you intend to display a large amount of data.
The following are examples of appropriate uses:
- Updating a single record.
- Modifying few fields of related child records.
- Perform one or more simple calculations and then update a record.
- Updating a record
Support users can assign cases (assign to queue) to themselves by clicking on "Accept" button present in Case detail page. On click on "Accept" button, system will change the case ownerid to current logged in user. Below is sample code:
- Updating child records or list of records
Notify Contacts of Account to update their Contact details.
Create a checkbox field(contact_update_required__c) in Contact. Create a workflow rule which will send
email to all contacts to update their contact details whenever checkbox field is
true. Create a related list button for Contact object “Update Contact Details”
and add it to Contact related list on Account page layout. Whenever this button is clicked, onclick javascript modify the checkbox field to true in all related contacts of Account.
- Performing logic by calling apex method
There are few scenarios where you want to perform complex logic in apex class and want to execute that logic on click of button. For example, you want send notifications to attendees of event based on some logic. For this, you need to create global class and create webservice method and then call it from onclick javascript.
- Performing synchronous and asynchronous calls.
- Query,create,edit,delete,undelete,merge and search records.
- Convert lead,send email and initiate approval process.
- Use describe to get object and fields information.
Refer below URL for more reference on AJAX toolkit: