简体   繁体   English

如何使用 API 添加 salesforce 社区用户?

[英]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.

相关问题 如何获得安全令牌? …Chatter Free Salesforce用户-带API的PE - How do I get a Security Token? … Chatter Free Salesforce User - PE w/ API 如何在VS 2015 Community Edition中添加存储过程 - How do I add stored procedures in VS 2015 Community Edition 如何使用Facebook graph API判断用户是否在线? - Using the Facebook graph API how do I tell if a user is online or not? 如何使用c#中的Web / REST API在salesforce中创建用户? - How to create user in salesforce using Web/REST API from c#? 如何在C#中为SalesForce API创建新的Profile对象 - How do I create a new Profile Object in C# for the SalesForce API 调用Salesforce API使用ASP.net添加销售线索 - Call Salesforce API to Add Leads using ASP.net 如何从弹出消息导航到新页面? 我正在使用 Xamarin 社区工具包弹出窗口 - How do I navigate to a new page from a Popup message? I'm using the Xamarin Community Toolkit Popup 如何将用户控件添加到工具箱? - How do I add a user control to toolbox? 如何将 api 添加到服务器? - How do I add an api to server? 使用 Google Admin API (C# /.Net) - 如何向用户添加第一个关系? - Using Google Admin API (C# / .Net)-- how can I add a first relationship to a user?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM