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

Getting results from Perl Sub Query


I am a bit of an amateur coder so please forgive my ignorance.

I am trying to have the results of a sub query returned in Perl.

my $result = $sforce->do_query("Select FirstName,Account.Name,LastName,Title,Description,(SELECT Note.Body,Note.Title FROM Contact.Notes where Note.title like '%resume%') From Contact where FirstName like '%abcd%'");

    foreach my $row (@$result) {
      print $row->{FirstName}.";".$row->{LastName}.";".$row->{Notes}.";\n";
I get this:

How do I get the results of the query, i.e. the Note Body and Note Title now?


Hi ,

 i am new to salesforce .
We are using the WWW::Salesforce PERL package to connect to the Salesforce Portal . Could you tell me what you did
to connect to salesforce (any change in the package etc.)
Initially we had problem in connecting to the Salesforce portal itself , then we changed the proxy from https:// to http://  and we got connection to the salesforce. We got session Id also .

 After that when we try to querythe salesforce our program aborts saying
"500 Connect failed: connect: Connection refused; Connection refused at //pkgs/linux/intel/perlmods_intcrm/5.8.8.rhas3.x86/lib/site_perl//5.8.8/WWW/ line 518"
If we go to the line number 518 of Salesforce package , it corresponds the session_header call.The corresponding code is
my $client = $self->get_client();
        my $r = $client->query(
            SOAP::Data->name( 'queryString' => $in{'query'} ),

 Then we used data dumper to see what the "sforce" variable in query passes ,
$VAR1 = bless( {
                 'sf_uid' => '00520000000nkSBAAY',
                 'sf_pass' => 'password',
                 'sf_sid' => '440400D200000000CXT!AREAQPvnCxWV3G0NLeGmDM.ie7AD5lJ4h_.swzsS486oT8ZqhRXr9WvnlnCfXlzbKUWhPEW0B2CMbwXjH1Z6ITWCAMuRnNhd',
                 'sf_serverurl' => '',
                 'sf_user' => 'username' <mailto:''>
              }, 'WWW::Salesforce' );

Our sample code is
use WWW::Salesforce;
use Data::Dumper;
use Crypt::SSLeay;
my $sforce =  WWW::Salesforce->login( username => '', password =>  '' ) or die "not connectedte $!";
print "connected \n";
my  $query = "SELECT Id,Name FROM Account";
print Dumper($sforce);
my $result =  $sforce->search('searchString' => $query);

Here's how I connect:

sub Connect {
    # Authenticate with the Salesforce API based on command line parameters.
    $sforce = WWW::Salesforce::Simple->new(
            'username' => '',
            'password' => ''
and this is how I query:

      my $result = $sforce->do_query("Select Title,Body from Note where ParentId='$IDVal'");

      foreach my $row(@$result) {
Hi ItCommander,
   Thanks for your reply, I am using the same but no luck . Initially i had trouble connecting to salesforce , so in the package
i changed the proxy from https:// to http://.
  Did you do any change at the package level.
Are you sure the password is right?

You have to add the security token to it.

i.e. if the password is "Password" and the token is "010Z", the password would be "Password010Z"

I did not change anything at the package level
I am using the security token also ...
I am getting error like
500 Can't connect to (connect: Connection refused) at //pkgs/linux/intel/perlmods_intcrm/5.8.8.rhas3.x86/lib/site_perl//5.8.8/WWW/ line 520
Hmmm.. I am not sure.

Did you try from a different computer under different network settings?

My guess is that it is more of a connection issue not a package issue.

I am using my organization network (It is in trusted connection) ....

Then I need to  test this from my home computer ....
Anyone got the answer for that relationship query. I have trouble in getting related list's value - related_lookup__r.field__c. I am gettting null value for this field