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
Bob BarraccaBob Barracca 

Updating accounts from Perl

Greetings All,

I am trying to update accounts using the WWW::Salesforce module in Perl, but I am not having any success.  I am able to query successfully and get results.  I can execute update commands without seeing errors, but the records never update.  For example:

-----------------------------
use WWW::Salesforce::Simple;
use SOAP::Lite;

print "Connecting to salesforce...\n";
my $sf = WWW::Salesforce->login( username => 'XX', password => 'XX' );
print "  Done.\n";

$sf::Constants::TYPES{Account}->{Account_Export__c} = 'xsd:boolean';

my $query = "SELECT id,Name,account_export__c, business_id__c, billingstate FROM Account WHERE id = '0014000000GNmKmAAL'" ;

print "Running query...\n";
my $result = $sf->query('query' => $query);
print "Loop results\n";

foreach my $elem ($result->valueof('//queryResponse/result/records'))
{
    @idstring = map{$_}(@{$elem->{id}});
     my ($id1, $id2) = splice(@{$elem->{Id}},0,2);
    print "QUERY RESULT: $elem->{id} $id1 : $elem->{Name} :  $elem->{BillingState}  : $elem->{Business_ID__c} : $elem->{Account_Export__c}\n";
   
    $uphash{type} = "Account";
    $uphash{id} = $id1;
    $uphash->{Name} = "WLV - Parasol Bar";
    $uphash->{"Account_Export__c"} = false;
   
    $upres = $sf->update(%uphash);
    print "UPDATE RESULT: $upres \n";
   
}

print "    Done.\n";


------

Here is the script output:
Connecting to salesforce...
  Done.
Running query...
Loop results
QUERY RESULT: ARRAY(0x1cd4ec8) 0014000000GNmKmAAL : Parasol Bar :  NV : a1234 : true
UPDATE RESULT: 1
    Done.

-------

So the update command returns 1, but the record does not actually get updated.  I have also tried hardcoding the id just for testing like this:
$uphash{id} = "0014000000GNmKmAAL";

because a number of posts I saw revolved around bad Ids, but it still does not work.  I am connecting as a Salesforce Administrator user and I checked all my rights so that should not be an issue.

Any assitance would be greatly appreciated.

Thanks,
Bob


Bob BarraccaBob Barracca
I found my silly syntax mistake.  I am not sure how I got there in the first place, but I changed:

    $uphash->{Name} = "WLV - Parasol Bar";
    $uphash->{"Account_Export__c"} = false;

to

    $uphash{Name} = "WLV - Parasol Bar";
    $uphash{"Account_Export__c"} = false;

And everything works perfectly now.
CrmzepherCrmzepher

Hello Bob,

I´m glad that you found the error in your code. I was wondering if you could give your advice on what we are trying to accomplish.

We want to pass several custom fields back into SF via Perl in the Task Activity area. My question is that beyond your code example displayed here how have you tied Perl into SF via an Admin login? What version of Perl are you using? My Perl programmer is having problems connecting to SF.

Once connected is there any difference in updating custom fileds versus standard fields? We are passing back the "Call Duration", "Call End Time", and "Call Recording Url" into the Task Activity table. We have to match up the Task ID that has been passed into our DB once the call was first initiated. 

Follwing you model code here we have to first query SF for to find the correct Task ID and then upsert the custom fields.

Thanks,

Sam

PerlPerl
Hi Bob
 
   Could you tell me the steps to connect to salesforce from perl , I am new to salesforce. I amgetting the following error
when i try to connect to salesforce from perl
 
500 Server closed connection without sending any data back at //pkgs/linux/intel/perl/5.8.8.rhas3.x86/lib/site_perl/5.8.8/WWW/Salesforce.pm line 469

 
This line number 469 corresponds to login id and password , but we dont have any problem with login id and password, even i am able to do telnet from the machine.
 
We don't know what is the problem , could you help me telling the steps how to connect to the salesforce from perl.
 
Thanks,
Prasanna
prasannavenkatesh.murugesan@etrade.com