You need to sign in to do that
Don't have an account?
BMT-David
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.
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;
}
}
All Answers
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;
}
}
Many Thanks. That was a full response.
If anyone can point me in the right direction that would really help me out.