You need to sign in to do that
Don't have an account?
A duplicate value was specified for field 'LastName' in object 'Contact
Hi,
"A duplicate value was specified for field 'LastName' in object 'Contact', duplicate value 'Prabhu' prior value 'Muthu'"
this is an exception while am trying to upsert a value in salesforce using partner wsdl and jax-ws.
I am fetching RDBMS table values using jdbc and trying to insert the values into salesforce.
Here is my code snippet,
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
Upsert upsert = new Upsert();
SObject sobj = new SObject();
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
sobj.setType(objname);
sobj.setId("objectfromjava");
for (int i = 0; i < clc; i++) { // clc - number of columns : column count
Element insert = doc.createElement( columnValue[i]);
insert.appendChild(doc.createTextNode(rs.getString((i+1)).toString()));
sobj.getAnies().add(insert);
}
upsert.getSObjects().add(sobj);
}
port.Upsert(upsert);
The same error is happening for create call also..
what will be my problem? Please help me out!!
Oh, and the most likely problem is that you're not creating a new sobject for each row, so you just keep adding elements over and over to the same one sobject.
All Answers
Can you post what your request XML looks like? the error would indicate that you have the lastName field twice, e.g. <lastName>foo</lastName><lastName>bar</lastName>
Oh, and the most likely problem is that you're not creating a new sobject for each row, so you just keep adding elements over and over to the same one sobject.
Thats correct Simon, this operation should be done inside iteration(while loop)
SObject sobj = new SObject();
Thank you Mr. Simon, I will try out...
Thank you Zindalabhinav!!