You need to sign in to do that
Don't have an account?
![aravind swaminathan aravind swaminathan](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
Regarding Updating Salesforce Contact Information
Hello,
We are trying to update the user profile data(ie Contacts information).When i am trying to do
SaveResult[] rsults=binding.update(userList);
I am getting an error -Invalid format of Id.I am sending Id as employee number.Can you please let me know if Id is salesforce identifier?If yes,How can i get that Id?And also please advise me if i am using the right api method to update Contact Information?
Thanks.
We are trying to update the user profile data(ie Contacts information).When i am trying to do
SaveResult[] rsults=binding.update(userList);
I am getting an error -Invalid format of Id.I am sending Id as employee number.Can you please let me know if Id is salesforce identifier?If yes,How can i get that Id?And also please advise me if i am using the right api method to update Contact Information?
Thanks.
The sObject Id field should be the 15 or 18 character Salesforce Base64 Id. See What are Salesforce ID's composed of? (http://salesforce.stackexchange.com/q/1653/102)
If you want to use an employee Id you should create a custom field on Contact to store this Id. Mark it an a unique external Id. See What is an external ID? (https://help.salesforce.com/apex/HTViewHelpDoc?id=faq_import_general_what_is_an_external.htm&language=en)
Then you can swtich to an upsert rather than an update. The upsert call will using the External Id to find the correct record to update. See Upsert() (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_upsert.htm)
For Manager/ManagerId field, what is the encoding thats used. i tried decoding using base64 and it didnt work.
I'd expect the ManagerId field to be a standard 15/18 character Salesforce ID field with a User Id.
I am trying to use upsert to update a record and i get this message-"Duplicate Username.<br>The username already exists in this or another Salesforce organization. Usernames must be unique across all Salesforce organizations. To resolve, use a different username (it doesn't need to match the user's email address). ".
It works for certain users but not all?The empoyee number, email address match but i get this exception.
Another thing is when i try to insert new user, i get an error asking to "Business unit must be defined by user".I am already passing company name,division,district etc.
Can you please help me in this regard.
Thanks.
I'm not sure on the business unit requirement. I'd suggest raising a new question to investigate that explicity.
If you are doing an Upsert without specifying the Id field for the entity in question you need to set the externalIdFieldName parameter.
From the docs (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_upsert.htm):
ExternalIDFieldName
Contains the name of the field on this object with the external ID field attribute for custom objects or the idLookup field property for standard objects. The idLookup field property is usually on a field that is the object's ID field or name field, but there are exceptions, so check for the presence of the property in the object you wish to upsert().
So make sure you are setting externalIdFieldName to "Username". It should be possible to use this field, as it has the idLookup (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_user.htm#username) property.
userFields[1] = makeElement("Alias", u.firstName.Substring(0, 1) + lastName);
userFields[2] = makeElement("CompanyName", u.companyName);
userFields[3] = makeElement("Department", u.department);
userFields[4] = makeElement("Division", u.division);
userFields[5] = makeElement("Email", u.email);
userFields[6] = makeElement("EmailEncodingKey", u.emailEncodingKey);
userFields[7] = makeElement("EmployeeNumber", u.employeeNumber);
userFields[8] = makeElement("Fax", u.fax);
userFields[9] = makeElement("FederationIdentifier", u.federationIdentifier);
userFields[10] = makeElement("FirstName", u.firstName);
userFields[11] = makeElement("LanguageLocaleKey", u.languageLocaleKey);
userFields[12] = makeElement("LastName", u.lastName);
userFields[13] = makeElement("LocaleSidKey", u.localeSidKey);
userFields[14] = makeElement("MobilePhone", u.mobilePhone);
userFields[15] = makeElement("CommunityNickname", u.firstName.Substring(0, 1) + "_" + u.lastName);
userFields[16] = makeElement("Phone", u.phone);
userFields[17] = makeElement("TimeZoneSidKey", "America/Chicago");
userFields[18] = makeElement("Username", u.email);
userFields[19] = makeElement("EmployeeNumber__c", u.employeeNumber);
userFields[20] = makeElement("Title", u.title);
userFields[21] = makeElement("ProfileId", "xyz");
userFields[22] = makeElement("ManagerId", u.manager);
newUser.type = "User";
newUser.Any = userFields;
userList[x] = newUser;
UpsertResult[] results = binding.upsert("EmployeeNumber__c", userList);
for (int j = 0; j < results.Length; j++)
{
if (j == x)
{
if (results[j].success)
{
successes++;
else
{
errors++;
for (int i = 0; i < results[j].errors.Length; i++)
{
Error err = results[j].errors[i];
Console.WriteLine("Errors were found on item " + j.ToString());
Console.WriteLine("Error code is: " + err.statusCode.ToString());
Console.WriteLine("Error message: " + err.message);
}
}
}
}