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
BoltonBolton 

Perl - WWW::Salesforce, 'value not of required type' when updating a custom Numeric field.

Hello,

 

I'm sure we're missing something blindingly obvious here. We have a trivial little perl script using WWW::Salesforce::Simple, to update a custom object.

 

We have a test case setup, as follows:

 

 

 

$WWW::Salesforce::Constants::TYPES{Data_Questionnaire__c}->{Custom_Number__c} = 'xsd:double'; $WWW::Salesforce::Constants::TYPES{Data_Questionnaire__c}->{Custom_Results__c} = 'xsd:string'; my %data = ( id => $id, Custom_Number__c => 5, Custom_Results__c => 'http://someurl.com' ); my $result = $sf->update(type => 'Data_Questionnaire__c', %data);

 

We receive the following error, despite ensuring the the type is of 'xsd::double', and the custom field 'Custom__Number__c' is of type Numeric:

Custom Number: value not of required type: 5

 


Has anyone experienced this issue before? Any information would be greatly appreciated.

 

Best Answer chosen by Admin (Salesforce Developers) 
BoltonBolton

Seems that we since last upgraded the WWW:Salesforce class, a change has been made to the way it accesses the types hash in WWW::Salesforce::Constants, which broke the daft way we were adding new types (see my original post). We should have been using the 'register type' method to, well, register types, as opposed to accessing the TYPES hash directly.

 

For those that run into this issue when trying to update custom Numeric fields, you need to something similar to this, to register the type:

WWW::Salesforce::Constants->register_type($object,$field,'xsd:double');


Thanks

 

 

 

All Answers

SuperfellSuperfell
Have you looked at the actual XML generated ?
BoltonBolton

Seems that we since last upgraded the WWW:Salesforce class, a change has been made to the way it accesses the types hash in WWW::Salesforce::Constants, which broke the daft way we were adding new types (see my original post). We should have been using the 'register type' method to, well, register types, as opposed to accessing the TYPES hash directly.

 

For those that run into this issue when trying to update custom Numeric fields, you need to something similar to this, to register the type:

WWW::Salesforce::Constants->register_type($object,$field,'xsd:double');


Thanks

 

 

 

This was selected as the best answer
dislusivedislusive

Thanks, Bolton.  That was a total lifesaver!

 

My scripts broke when I upgraded to:

SOAP-Lite-0.710.08 (cpan)

WWW-Salesforce-0.090 or WWW-Salesforce-0.10 (cpan)

 

I use perl scripts to query/upload attachments to custom SF tables.

 

When trying to install WWW-Salesforce-0.10, via CPAN or during "make test", I get the error:

"t/WWW-Salesforce....18/29 Unable to find a de-serializer for the type {http://www.w3.org/2001/XMLSchema}base64binary at t/WWW-Salesforce.t line 176"

 

This package doesn't install correctly, via CPAN, and I manually compiled/installed from the .cpan directory.

 

 

 I used this, within my scripts, prior:

WWW::Salesforce::Constants::TYPES{Attachment}->{Body} = 'xsd:base64Binary';

 

 When trying to upload a file via script, I get this error (with the new SF/SOAP packages):

Can't locate object method "TYPES" via package "WWW::Salesforce::Constants"

 


If you remove that line, you get the same error as if running "make test" on the WWW::Salesforce source code:

"Unable to find a de-serializer for the type {http://www.w3.org/2001/XMLSchema}base64binary"

 

Using the following line corrects the scripts, to allow base64 encoded uploads, again:

"WWW::Salesforce::Constants->register_type(Attachment,Body,'xsd:base64Binary');"

 

 

 

WWW::Salesforce::Constants->register_type($object,$field,'xsd:double'); 
dclaardclaar

Added these lines to .cpan/build/WWW-Salesforce-0.11/t/WWW-Salesforce.t:

WWW::Salesforce::Constants->register_type("Attachment","Body",'xsd:base64Binary');
WWW::Salesforce::Constants->register_type("Document","Body",'xsd:base64Binary');" 
Then it installed.
jhagenjhagen

I need some clarification on this.   I have created a custom "Numeric" type on the Salesforce object Account, but when I go to add a record, I get "Unable to find a de-serializer for the type {http://www.w3.org/2001/XMLSchema}Integer at /usr/lib/perl5/site_perl/5.8.8/WWW/Salesforce.pm line 115." if I set the type to "Integer" or "Numeric".  If it is set to "int", then it doesn't have a problem with de-serializing, but I get "value not of required type:" from Salesforce. 

 

If the custom field is a string, it has no problem.

 

How do I add a record with a custom numeric field in a Salesforce object using Perl?

jhagenjhagen

OK, it is a bit counter-intuitive, but apparantly Numeric is "double".  When I set the type to double, I can access the Numeric fields in a salesforce object.