Reply
Contributor
BMT-David
Posts: 4
0
Accepted Solution

Is it possible to create a Chatter Free user from a Contact Button?

This is Non-Profit where we are trying to integrate the community of volunteers through Chatter Free user accounts.

 

The first step would be creating a button on Volunteer Contact Records creating Chatter Free user accounts for each volunteer, using the contact email.

 

I have succeeded creating a Chatter Free account through apex data loader.

 

I am looking for limitations on this matter... but as wierd as it looks, I haven't found any.

 

Any suggestions?

 

Many thanks.

 

David.

Super Contributor
Jia Hu
Posts: 839
0

Re: Is it possible to create a Chatter Free user from a Contact Button?

Try the code below,

 

VF page:

<apex:page standardController="Contact" extensions="ChatterFree" action="addUser">
</apex:page>

 

Apex class:

public class ChatterFree {

private final Contact acct;

public ChatterFree(ApexPages.StandardController stdController) {
this.acct = (Contact)stdController.getRecord();
}

public PageReference addUser() {
if(acct.id != null) {
Contact acc = [Select Lastname, Email From Contact Where Id =: acct.id];
User auser = new User();
auser.Lastname = acc.Lastname;
auser.Email = acc.Email;
auser.Username = 'Chatter.Free@XXX';
auser.Alias = 'C.FX';
auser.CommunityNickname = 'Chatter.FreeX';
auser.ProfileId = '00e1000XXXXX';  //Standard Chatter Free Profile Id
auser.LocaleSidKey = 'ja_JP';
auser.EmailEncodingKey = 'ISO-2022-JP';
auser.LanguageLocaleKey = 'en_US';
auser.TimeZoneSidKey = 'Asia/Tokyo';


insert auser;
}
return null;
}

}

Contributor
BMT-David
Posts: 4
0

Re: Is it possible to create a Chatter Free user from a Contact Button?

Many Thanks. That was a full response.