[英]How do I add a salesforce community user using the API?
I've downloaded the API WSDL and added it to my C# project and have many successful integrations running throught it both bringing down and upserting data.我已经下载了 API WSDL 并将其添加到我的 C# 项目中,并且通过它运行了许多成功的集成,既可以降低数据也可以插入数据。 I'm having a lot of trouble with creating community user accounts for our learning management system though.不过,我在为我们的学习管理系统创建社区用户帐户时遇到了很多麻烦。
I can't tell if I need to supply an account, or a contact, or a user type, and no matter what I try I end up with an error that doesn't lead me to a logical fix.我不知道我是否需要提供帐户、联系人或用户类型,无论我尝试什么,最终都会遇到一个无法让我找到合乎逻辑的修复的错误。
I think i'm closest with the below configuration, which is giving me this error: "You can't create a contact for this user because the org doesn't have the necessary permissions. Contact Salesforce Customer Support for help."我认为我最接近以下配置,这给了我这个错误:“您无法为该用户创建联系人,因为该组织没有必要的权限。请联系 Salesforce 客户支持寻求帮助。”
This is my C# code I'm trying to create a User account with:这是我正在尝试创建用户帐户的 C# 代码:
public UpsertResponse UpsertLearningUser()
{
SFProd.User U = new SFProd.User();
U.Id = UserID;
U.Username = UserName;
U.Alias = TechCode;
U.CommunityNickname = FirstName + "." + LastName;
U.FirstName = FirstName;
U.LastName = LastName;
U.MiddleName = MiddleName;
U.Title = Title;
U.Department = Department;
U.Division = Division;
U.IsActive = Active;
U.IsActiveSpecified = true;
U.UserPermissionsChatterAnswersUser = true;
U.UserPermissionsChatterAnswersUserSpecified = true;
//U.UserPermissionsMobileUser = true;
//U.UserPermissionsMobileUserSpecified = true;
U.Phone = Phone;
U.EmployeeNumber = ADPNumber;
U.NS_Internal_ID__c = NSEmployeeID.ToString();
U.Employee_ID__c = double.Parse(EmployeeID.ToString());
U.Employee_ID__cSpecified = true;
U.Zone__c = Department;
U.Region__c = Division;
U.Certification_Level__c = CertificationLevel;
if (CertificationLevelDate != DateTime.Parse("1/1/1900"))
{
U.Certification_Level_Date__c = CertificationLevelDate;
U.Certification_Level_Date__cSpecified = true;
}
U.Country = Country;
U.State = State;
U.City = City;
U.PostalCode = PostalCode;
U.Street = Street;
U.Email = Email;
U.TimeZoneSidKey = "America/Chicago";
U.EmailEncodingKey = "ISO-8859-1";
U.ProfileId = "00ef10000016tfvAAA";
U.LanguageLocaleKey = "en_US";
U.ContactId = ContactID;
List<SFProd.sObject> Objs = new List<SFProd.sObject>();
Objs.Add(U);
return new UpsertResponse(SFConnection.RunUpsert("Username", Objs)[0], UserID);
}
Has anyone else done this sucessfully?有没有其他人成功地做到了这一点? or have any idea what I'm doing wrong?或者知道我做错了什么?
There is a special function for creating external users.有一个特殊的 function 用于创建外部用户。 Try a variation of the CreateExternalUser() function: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_sites.htm尝试 CreateExternalUser() function 的一种变体: https://developer.salesforce.com/docs/atlasexth/mex_apexclasses.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.