我想使用 SOAP API Partner WSDL 以编程方式在 SalesForce 中创建一个用户。这是我的代码:
import com.sforce.soap.partner.Connector;
import com.sforce.soap.partner.PartnerConnection;
import com.sforce.soap.partner.QueryResult;
import com.sforce.soap.partner.SaveResult;
import com.sforce.soap.partner.sobject.SObject;
import com.sforce.ws.ConnectionException;
import com.sforce.ws.ConnectorConfig;
import com.sforce.soap.partner.sobject.*;
import com.sforce.soap.partner.*;
import com.sforce.soap.*;
import com.sforce.*;
public class PartnerAPICreateUser {
/**
* @param args
*/
public static void main(String[] args) {
ConnectorConfig config = new ConnectorConfig();
config.setUsername("waprau@waprau.com");
config.setPassword("dhskjhkjgfkjsdhkfjg");
PartnerConnection connection = null;
try {
SObject user = new SObject();
user.setType("user");
user.setField("Alias", "abcd");
user.setField("DefaultGroupNotificationFrequency", "P");
user.setField("DigestFrequency", "D");
user.setField("Email", "abcd@pqrs.com");
user.setField("EmailEncodingKey", "ISO-8859-1");
user.setField("LanguageLocaleKey", "English");
user.setField("LastName", "Rau");
user.setField("LocaleSidKey", "En");
user.setField("TimeZoneSidKey", "America/Los_Angeles");
user.setField("Username", "abcd@pqrs.com");
user.setField("UserPermissionsCallCenterAutoLogin", "true");
user.setField("UserPermissionsMarketingUser", "true");
user.setField("UserPermissionsOfflineUser", "true");
connection = Connector.newConnection(config);
SaveResult[] results = connection.create(new SObject[] { user });
System.out.println("Created user: " + results[0].getId());
QueryResult queryResults = connection
.query("SELECT Id, Name from User "
+ "ORDER BY CreatedDate DESC LIMIT 5");
if (queryResults.getSize() > 0) {
for (SObject s : queryResults.getRecords()) {
System.out.println("Id: " + s.getField("Id") + " - Name: "
+ s.getField("Name"));
}
}
} catch (ConnectionException ce) {
ce.printStackTrace();
}
}
}
但是,当我执行这个 Java 程序时,它会给出以下输出,显示“创建的用户:null”:-(
Created user: null
Id: 005E0000001fb3vIAA - Name: Rau
Id: 005E0000001fVTTIA2 - Name: Chatter Expert
Id: 005E0000001fVU1IAM - Name: Wap Rau
转到 MyName > 设置 > 管理用户(在管理设置中)> 配置文件时的管理权限
你能告诉我有什么问题吗?
谢谢,
瓦普劳