You need to sign in to do that
Don't have an account?
margotq
Error when creating a new record with a blank 'long text area' field.
When using the API to create a new lead record, if we try to insert a blank value into a custom field of type "long text area", an error is returned.
If we change the blank string to a value (e.g. "x"), the new record is created without a problem.
Any ideas why?
OK
I have a function called Lead_Create that takes in a handful of string variables and generates a Lead record. One of the variables is named "iComments", which contains the text that I want to insert into the "Comments__c" field. Below is a snippet of the function:
Lead lead = new Lead();
lead.Email = iEmail.Trim();
lead.Comments__c = iComments.Trim();
sObject[] newLead = new sObject[]{ lead };
SaveResult[] sr = sfbinding.create( newLead );
if ( sr[0].success != true )
return "ERROR: " + sr[0].errors[0].message;
else
return sr[0].id;
When the string "iComments" is a blank string, the web code that calls this particular function Lead_Create generates the following error:
Error Type:
sfAPI (0x80004003)
Object reference not set to an instance of an object.
Which indicates that the function completely failed. When the string "iComments" is not blank, there is no error, and everything works as planned. I should note that this function was working prior to adding the "iComments" variable.
lead.Comments__c = iComments == null ? null : iComments.Trim();
Nope, no luck. The string isn't a null, because I am testing by actually setting the variable to a blank string and it still fails. I have other variables that are blank strings (phone number and other custom fields) and those have been working fine with the Trim() method.
Hmmm.