No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
Newer Version Available
AccountCreator Interface
Namespace
Usage
The ChatterAnswers.AccountCreator is specified in the registrationClassName attribute of a chatteranswers:registration Visualforce component. This interface is called by Chatter Answers and allows for custom creation of Account records used for portal users.
1public class ChatterAnswersRegistration implements ChatterAnswers.AccountCreator {1public String createAccount(String firstname, String lastname, Id siteAdminId) {
2 // Your code here
3}The implemented method must be declared as global or public.
AccountCreator Methods
The following are methods for AccountCreator.
createAccount(String, String, Id)
Signature
public String createAccount(String firstname, String lastname, Id siteAdminId)
Parameters
Return Value
Type: String
AccountCreator Example Implementation
This is an example implementation of the ChatterAnswers.AccountCreator interface. The createAccount method implementation accepts user information and creates an Account record. The method returns a String value for the Account ID.
1swfobject.registerObject("clippy.codeblock-2", "9");public class ChatterAnswersRegistration implements ChatterAnswers.AccountCreator {
2 public String createAccount(String firstname, String lastname, Id siteAdminId) {
3 Account a = new Account(name = firstname + ' ' + lastname, ownerId = siteAdminId);
4 insert a;
5 return a.Id;
6 }
7}This example tests the code above.
1swfobject.registerObject("clippy.codeblock-3", "9");@isTest
2private class ChatterAnswersCreateAccountTest {
3 static testMethod void validateAccountCreation() {
4 User[] user = [SELECT Id, Firstname, Lastname from User];
5 if (user.size() == 0) { return; }
6 String firstName = user[0].FirstName;
7 String lastName = user[0].LastName;
8 String userId = user[0].Id;
9 String accountId = new ChatterAnswersRegistration().createAccount(firstName, lastName, userId);
10 Account acct = [SELECT name, ownerId from Account where Id =: accountId];
11 System.assertEquals(firstName + ' ' + lastName, acct.name);
12 System.assertEquals(userId, acct.ownerId);
13 }
14}