MassNoteInsert.apex

Image:cookbook.jpg

Force.com Cookbook Sample Code
Chapter 7: Customizing Buttons and Links - Redirecting a User to an Edit, Detail, or List Page

To download all the code samples, access the Cookbook. - Image:Key_icon.gif

This Apex class is part of an example that shows how to create a new button that executes logic written in Apex.

global class MassNoteInsert{

	WebService static Integer insertNotes(String iTitle, String iBody, Id[] iParentIds) {

		Note[] notes = new Note[0];

		for (Id iParentId : iParentIds) {
			notes.add(new Note(parentId = iParentId, title = iTitle, body = iBody));
		}

		insert notes; //Bulk Insert
		return notes.size();
	}
}

Sample code provided by salesforce.com. All rights reserved.