You need to sign in to do that
Don't have an account?
Bob 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
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
$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.
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