• sk2006
  • NEWBIE
  • 0 Points
  • Member since 2006

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 8
    Replies
I've been having some trouble wrapping my head around this one. Hope someone can help. I'd really appreciate the help.

I want to reliably iterate ove the responses from my queries. Not sure how I'd do that when the URL for the results are different for query (//queryResponse/result/records') and querymore (//queryMoreResponse/result/records').

Can someone help me out with some sample code? I've been trying to translate the c++ code provided in the API doc to perl without any luck. This one doesnt work.

$r = $sf->query('query' => "select Id from Case" );
$numrecords = $r->valueof('//queryResponse/result')->{size};
my $done = "false";
if ( $numrecords > 0 ) {
        while ( uc($done) eq "FALSE" ) {
                foreach $elem ( $r->valueof('//queryResponse/result/records') ) {
                        print $elem->{Id}[0]."\n";
                }
                $done = $r->valueof('//queryResponse/result')->{done};
                if ( uc($done) eq "FALSE" ) {
                        $r = $sf->queryMore( 'queryLocator' => $r->valueof('//queryResponse/result')->{queryLocator} );
                        $numrecords = $r->valueof('//queryMoreResponse/result')->{size};
                        foreach $elem ( $r->valueof('//queryMoreResponse/result/records') ) {
                                print $elem->{Id}[0]."\n";
                        }
                } else {
                        $done = $r->valueof('//queryResponse/result')->{done};
                }
        }
} else {
        print "No records match criteria\n";
}

Message Edited by sk2006 on 05-23-2006 06:04 AM

How do I create multiple records with one create call? Currently I am doing this in a for loop but wanna try to minimize my calls.

            $r = $sf->create( type=>'CaseHist__c',
                        FieldName__c => "$_",
                        CaseId__c => "$caseid",
                        ContactId__c => "$contactid",
                        OldValue__c => "$old{$_}",
                        NewValue__c => "$new{$_}",
                        DateModified__c => "$gmtime"
            );


I'd appreciate any suggestions.
  • April 13, 2006
  • Like
  • 0
I am trying to  create an attachment using perl and the API. I am base64 encoding the string using MIME::Base64's encode_base64 method. Here's my create call:

        my $r = $sf->create( type=>'Attachment',
                    Body => "$filedata",
                    Name => "$uploaded_filename",
                    ParentId => "$caseid"
                    );

Here's what I get back:

$VAR1 = { 'success' => 'false', 'errors' => { 'fields' => undef, 'statusCode' => 'INVALID_TYPE_ON_FIELD_IN_RECORD', 'message' => 'Body: value not of required type: VGhpcyBpcyBhIHRlc3QgZm9yIHRoZSBhdHRhY2htZW50IGZlYXR1cmUuIE5vdCBjb21wcmVzc2lu ZyBiZWZvcmUgaW5zZXJ0IHlldC4=' }, 'id' => undef };

Can someone help please?
  • April 07, 2006
  • Like
  • 0
describeSObject gives me this:

$VAR1 = {
          'Body' => {
                    'Fault' => {
                               'detail' => {
                                           'fault' => bless( {
                                                             'exceptionMessage' => 'sObject type \'SelfServiceUser\' is not supported.',
                                                             'exceptionCode' => 'INVALID_TYPE'
                                                           }, 'InvalidSObjectFault' )
                                         },
                               'faultcode' => 'soapenv:Server',
                               'faultstring' => 'INVALID_TYPE: sObject type \'SelfServiceUser\' is not supported.'
                             }
                  }
        };

describeGlobal also does not list SelfServiceUser as an available type. Any ideas?

SK
  • March 24, 2006
  • Like
  • 0

I am new to Salesforce and SOAP development and having a bit of trouble getting started. I am not sure how I can employ the enterprise.wsdl file so I can start inserting (creating) records for my objects. I've tried, unsuccessfully, to change the Salesforce.pm itself from:

    my $client = SOAP::Lite
        ->deserializer(Salesforce::Deserializer->new)
        ->on_action( sub { return '""' } )
      ->uri('urn:partner.soap.sforce.com')
     ->proxy($self->{address});

to:

    my $client = SOAP::Lite
        ->service('file:/usr/local/lib/perl5/site_perl/5.8.5/enterprise.wsdl');

I am trying to test an insert (code 1 below) but get errors (error 1 below). The reason I thought I needs the wsdl file change in the module because before I was getting some errors without it.

code 1:

#!/usr/local/bin/perl
use CGI;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use Net::LDAP;
use Net::SMTP;
use SOAP::Lite;
use Salesforce;
use Data::Dumper;

        my $service = new Salesforce::SforceService;
        my $port = $service->get_port_binding('Soap');
        $port->login('username' => 'myusername@mycompany.com','password' => 'secret')
           || die "Could not login to salesforce.com";


        my @results = $port->create( 'type' => "Case",
                                'Contact_Info__c' => "test contact",
                                'Subject' => "test subject",
                                'Version_of_system__c' => "1.0",
                                'Reproduction_Steps__c' => "test 1 2 3",
                                'Always_Reproducible__c' => "true",
                                'What_you_expect_to_see__c' => "expectation",
                                'Expected_behavior_in_documentation__c' => "docsupportexistsval",
                                'Documentation_Reference__c' => "docsupportref",
                                'Additional_Information__c' => "additionalinfo" );
        foreach (@results) {
        print Dumper($_->result);
        }


error 1:

[Thu Mar 23 16:42:08 2006] x: document/literal support is EXPERIMENTAL in SOAP::Lite at /usr/local/lib/perl5/site_perl/5.8.5/SOAP/Lite.pm line 2818.
<h1>Software error:</h1>
<pre>String value expected instead of SOAP::Data reference
</pre>
<p>
For help, please send mail to this site's webmaster, giving this error message
and the time and date of the error.
</p>
<!-- warning: document/literal support is EXPERIMENTAL in SOAP::Lite at /usr/local/lib/perl5/site_perl/5.8.5/SOAP/Lite.pm line 2818. -->
[Thu Mar 23 16:42:09 2006] x: String value expected instead of SOAP::Data reference

 

***************before trying to use the wsdl file***************
code 2: same as code 1

error 2:

$VAR1 = {
          'success' => 'false',
          'errors' => {
                      'fields' => undef,
                      'statusCode' => 'INVALID_TYPE_ON_FIELD_IN_RECORD',
                      'message' => 'Always Reproducible: value not of required type: true'
                    },
          'id' => undef
        };


 

  • March 23, 2006
  • Like
  • 0
I need to create a cgi app that would mimic the self service portal functionality provided at the builtin portal.
 
First of all the reason for doing this is coz we want to customize the layout of the pages more than what SF provides. Specifically we want to include help popup windows for each of the fields.
 
Secondly, my question is how would I go about going this. My understanding is the I cannot retrieve the Self service user password. How do I authenticate users then?
 
I'd appreciate any help on this matter.
 
regards,
SK

Message Edited by sk2006 on 03-22-2006 02:05 PM

  • March 22, 2006
  • Like
  • 0
I am trying to  create an attachment using perl and the API. I am base64 encoding the string using MIME::Base64's encode_base64 method. Here's my create call:

        my $r = $sf->create( type=>'Attachment',
                    Body => "$filedata",
                    Name => "$uploaded_filename",
                    ParentId => "$caseid"
                    );

Here's what I get back:

$VAR1 = { 'success' => 'false', 'errors' => { 'fields' => undef, 'statusCode' => 'INVALID_TYPE_ON_FIELD_IN_RECORD', 'message' => 'Body: value not of required type: VGhpcyBpcyBhIHRlc3QgZm9yIHRoZSBhdHRhY2htZW50IGZlYXR1cmUuIE5vdCBjb21wcmVzc2lu ZyBiZWZvcmUgaW5zZXJ0IHlldC4=' }, 'id' => undef };

Can someone help please?
  • April 07, 2006
  • Like
  • 0
describeSObject gives me this:

$VAR1 = {
          'Body' => {
                    'Fault' => {
                               'detail' => {
                                           'fault' => bless( {
                                                             'exceptionMessage' => 'sObject type \'SelfServiceUser\' is not supported.',
                                                             'exceptionCode' => 'INVALID_TYPE'
                                                           }, 'InvalidSObjectFault' )
                                         },
                               'faultcode' => 'soapenv:Server',
                               'faultstring' => 'INVALID_TYPE: sObject type \'SelfServiceUser\' is not supported.'
                             }
                  }
        };

describeGlobal also does not list SelfServiceUser as an available type. Any ideas?

SK
  • March 24, 2006
  • Like
  • 0

I am new to Salesforce and SOAP development and having a bit of trouble getting started. I am not sure how I can employ the enterprise.wsdl file so I can start inserting (creating) records for my objects. I've tried, unsuccessfully, to change the Salesforce.pm itself from:

    my $client = SOAP::Lite
        ->deserializer(Salesforce::Deserializer->new)
        ->on_action( sub { return '""' } )
      ->uri('urn:partner.soap.sforce.com')
     ->proxy($self->{address});

to:

    my $client = SOAP::Lite
        ->service('file:/usr/local/lib/perl5/site_perl/5.8.5/enterprise.wsdl');

I am trying to test an insert (code 1 below) but get errors (error 1 below). The reason I thought I needs the wsdl file change in the module because before I was getting some errors without it.

code 1:

#!/usr/local/bin/perl
use CGI;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use Net::LDAP;
use Net::SMTP;
use SOAP::Lite;
use Salesforce;
use Data::Dumper;

        my $service = new Salesforce::SforceService;
        my $port = $service->get_port_binding('Soap');
        $port->login('username' => 'myusername@mycompany.com','password' => 'secret')
           || die "Could not login to salesforce.com";


        my @results = $port->create( 'type' => "Case",
                                'Contact_Info__c' => "test contact",
                                'Subject' => "test subject",
                                'Version_of_system__c' => "1.0",
                                'Reproduction_Steps__c' => "test 1 2 3",
                                'Always_Reproducible__c' => "true",
                                'What_you_expect_to_see__c' => "expectation",
                                'Expected_behavior_in_documentation__c' => "docsupportexistsval",
                                'Documentation_Reference__c' => "docsupportref",
                                'Additional_Information__c' => "additionalinfo" );
        foreach (@results) {
        print Dumper($_->result);
        }


error 1:

[Thu Mar 23 16:42:08 2006] x: document/literal support is EXPERIMENTAL in SOAP::Lite at /usr/local/lib/perl5/site_perl/5.8.5/SOAP/Lite.pm line 2818.
<h1>Software error:</h1>
<pre>String value expected instead of SOAP::Data reference
</pre>
<p>
For help, please send mail to this site's webmaster, giving this error message
and the time and date of the error.
</p>
<!-- warning: document/literal support is EXPERIMENTAL in SOAP::Lite at /usr/local/lib/perl5/site_perl/5.8.5/SOAP/Lite.pm line 2818. -->
[Thu Mar 23 16:42:09 2006] x: String value expected instead of SOAP::Data reference

 

***************before trying to use the wsdl file***************
code 2: same as code 1

error 2:

$VAR1 = {
          'success' => 'false',
          'errors' => {
                      'fields' => undef,
                      'statusCode' => 'INVALID_TYPE_ON_FIELD_IN_RECORD',
                      'message' => 'Always Reproducible: value not of required type: true'
                    },
          'id' => undef
        };


 

  • March 23, 2006
  • Like
  • 0