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
ABShellABShell 

how to validate return from sforceClient.Create ()

Hi:

For some reason the .getClassName() does not work for returns from Create,
but do work for Query() and Update().

How do I print out the error message of Create?



---------------------------------------------------
var saveResult = sforceClient.Create(sObjects);

//report object does not support this method.....
if (saveResult.getClassName() == "SaveResult") {
alert("Save successful");
}

else if (saveResult.getClassName() == "SoapFault") {
alert(saveResult.detail.toString());
}
---------------------------------------------------------
DevAngelDevAngel
Create returns an array of SaveResults, so you can check for dltypeof(result).toLowerCase() = "array" or take the opposite approach and do if (result.getClassName() == "SoapFault") which would indicate and error.
ABShellABShell
I was trying to do a result.getClassName() but failed.
After print out the result, I think it is an unhandled error within Beta1.
----------------------------------------------------
saveResult = salesforce.create(...); //some fields has numbers but input value is empty
saveResult.toString() have following printout:
faultString: java.lang.NumberFormatException: empty String
faultcode: soapenv: Server
-----------------------------------------------------

For Beta2 it is ok. Just post it as a remider.