自动创建社区用户 [英] automate creating communities user
本文介绍了自动创建社区用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在 Salesforce 中自动化创建社区用户的过程?我正在考虑触发联系人,然后使用社区许可证创建用户记录.这可能吗?
Would it be possible to automate the process of creating a communities user in Salesforce? I was thinking of a trigger on the contact that would then create the user record with the communities license. Would this be possible at all?
谢谢.
推荐答案
是的,应该是这样的
Contact con = [select id,email,firstName,lastname,accountId from Contact where Id =:contactId];
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.EmailHeader.triggerUserEmail = false;
dmo.EmailHeader.triggerOtherEmail = false;
dmo.EmailHeader.triggerAutoResponseEmail = false;
dmo.optAllOrNone = false;
// create portal user
string nick = con.email!=null?con.email.substring(0, con.email.indexOf('@')):'';
nick += Datetime.now().getTime();
User newUser = new User(
alias = createAlias(con.firstName, con.lastName),
email = con.email,
emailencodingkey = 'UTF-8',
firstname = con.firstName,
lastname = con.lastname,
languagelocalekey = 'en_US',
localesidkey = 'en_US',
contactId = con.Id,
timezonesidkey = 'Asia/Dubai',
username = con.email,
CommunityNickname = nick,
ProfileId = .......,
IsActive = true);
newUser.setOptions(dmo);
insert newUser;
这篇关于自动创建社区用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文