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
bildbild 

Missing required field, but no fault detected in PERL


I am using the 0.55 of the Salesforce.pm access objects I downloaded from sf.

I attempt to create a lead like this:

my $name_last = "Dude" ;

my $company = "" ;

my $port = &doLogin() ; # works fine.

my $result = $port->create('type' => 'Lead',
'LastName' => $name_last,
'Company' => $company,
) ;

if ($result->fault()) {
... throw an error ...
}

I do NOT see a fault (I have detected faults for bad SOQL syntax, so at least some of the time, it is working). But the object in //createResponse/result looks like:


$VAR1 = {
'success' => 'false',
'errors' => {
'fields' => 'Company',
'statusCode' => 'REQUIRED_FIELD_MISSING',
'message' => 'Required fields are missing: [Company]'
},
'id' => undef
};

So my questions are:

1. If the action did not succeed, why did $result->fault() not return true?
2. If a field (like Company) is required, does that mean that there HAS to be printable characters in there? (Neither empty string nor a string with a space (" ") will do).
3. Is there a way, using the website or otherwise, to make it so that 'Company' is not required in a Lead?
Ron HessRon Hess
my guess on this (from debugging inside the SOAP::Lite seralizer)
is that your empty string is getting "optimized" down to nothing ,
and so no string is sent over the wire in the SOAP create() call.

Another very possible problem is that it is a required field,
and that the empty string does not qualify as a valid value for a required field.

if i had to guess, i'd say the later.

if this is a problem, you could just pass "none", or "self" into the create call ?
bildbild

Certainly, I can pass something to 'Company' like 'none', that is my current hackaround. I am actually more concerned about the fact that, despite the fact that the action was unsuccessful, there was no 'fault' detected by the result object's 'fault' routine.

IMO, fault() should always be true if the action was unsuccessful. Otherwise, I have to write my own version of fault() that checks fault() AND THEN, depending on the action in question, look at the specific type of response object to see if it indicates failure.

If we change Salesforce.pm's fault(), faultstring() should follow the same logic.
Ron HessRon Hess
soap fault does not equal API error

I believe the $response->fault() is at the soap::lite level,
and indicates only that the server on the other end
did or did not return a valid soap response.

Since the API communication did succeed and return a valid, formated SOAP message,
there is no fault().

Now, you still need to check for "error" at the API level, so I've modified
my module to also check for this by opening the response and looking at
the 'success' => 'false', and 'errors' elements of the response

sub error { my $self = shift; my $r = shift; my $detail = shift;
if ($r->fault() ) {
$self->{'croak_errors'} and croak
"\ncode >",$r->faultcode(), "",$r->faultstring(), "
}
if ($r->valueof("//result/errors")) {
# print more contents of the error package
carp Dumper $r->valueof("//result/errors");
# croak ??
}
}

I added a call to this sub to each of my query, create, update, delete methods allowing
me to find out about faults AND errors from the API.

ron hess

Message Edited by Ron Hess on 10-17-2005 11:28 AM

Message Edited by Ron Hess on 10-17-2005 11:29 AM