function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SanalSanal 

Unable to Upsert

Hi,
 
I have a custom object with just four custom fields. I'm unable to upsert while i'm able to update. What is that i'm doing wrong here? Please help!
 
var recObject = new Sforce.Dynabean("Process__c");
recObject.set("Name","myName");
recObject.set("control__c","myControl");
recObject.set("to_control__c", "newControl");
recObject.set("parameters__c", "someid");
recObject.set("ExternalId__c", "01");
//recObject.set("Id","a0D40000000gOxXEAU"); //used for update
 
var result = sforceClient.upsert("ExternalId__c",recObject)[0];
//var result = sforceClient.update(recObject)[0]; //this works fine.
 
if (result.success==true)
alert("Success");
else alert("failed");
---------------------------
 
Ajax Version used:
 
 
Thanks in advance,
Sanal
DevAngelDevAngel
Hi Sanal,

What is the error that you are seeing?
SanalSanal
Hi Dave,
 
Thanks for replying.
 
In Netscape, I'm getting an error as "result has no properties".
 
I confirmed that the data is not getting upserted (in both Netscape and IE).
 
Regards,
Sanal
Ron HessRon Hess
To see the entire result, including the error message ( if any )
remove the [0]

so
var result = sforceClient.upsert("ExternalId__c",recObject)[0];

var result = sforceClient.upsert("ExternalId__c",recObject);

then you can look at the result and see the entire response, which should have a fault message if the call is not working.
SanalSanal

Thank You Ron.

I was really wondering how I can get precise error messages when I'm doing something wrong.

I finally figured it out why the upsert was not working. That was a terrible mistake from my side. I gave {!API_Partner_Server_URL_60} in the sforceClient.Init() call. {!API_Partner_Server_URL_70} made everything right and perfect, since upsert was supported from version 7.0 onwards.

Regards,
- Sanal