You have ProfileId="00590000002Px2vAAC" however 005... is not a profile its a user, profiles start with 00e. Use one of the schema/query tools (e.g. SoqlX, Eclipse Plugin, etc) to find the right profile Id.
invalid cross reference id while Creating a new User in SalesForce
-
09-07-2023 - |
Pregunta
while Creating a new User in SalesForce If I Give a ProfileID which is already exists.
invalid cross reference id
User[] AddUser = new User[1];
User objuser = new User { Username = "balaji.balumca@gmail.com",
Alias = "Balu", // The ID of the user profile (Standard User, System Administrator, etc).
ProfileId = "00590000002Px2vAAC",
Email = "balaji.balumca@gmail.com",
EmailEncodingKey = "ISO-8859-1",
FirstName="Balaji",
LastName = "Balu",
LanguageLocaleKey = "pt_BR",
LocaleSidKey = "pt_BR",
TimeZoneSidKey = "America/Sao_Paulo" };
AddUser[0] = objuser;
SaveResult[] saveResults = _service.create(AddUser);
Solución
Otros consejos
private void CreateUser()
{
var _service = new SforceService();
var login = _service.login(ConfigurationManager.AppSettings["username"], ConfigurationManager.AppSettings["password"]);
User[] AddUser = new User[1];
User objuser = new User
{
Username = "Pavankumar.r@gmail.com",
Alias = "RPK",
// The ID of the user profile (Standard User, System Administrator, etc).
ProfileId = "00e90000001CcTnAAK",
Email = "Pavankumar.r@gmail.com",
EmailEncodingKey = "ISO-8859-1",
FirstName = "Pavan",
LastName = "Kumar",
LanguageLocaleKey = "pt_BR",
LocaleSidKey = "pt_BR",
TimeZoneSidKey = "America/Sao_Paulo"
};
AddUser[0] = objuser;
SaveResult[] saveResults = _service.create(AddUser);
string result = "";
if (saveResults[0].success)
{
//
}
else
{
//
}
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow